XML highcharts file creation using java - java

the question is how to create this xml file exactly for me to be able to use it in the get function of highcharts? The CSV file is created rapidly but now i want to create the xml file from the back end which is java.
<chart>
<categories>
<item>..</item>
</categories>
<series>
<name>xxx</name>
<data>
<point>1</point>
<point>2</point>
<point>3</point>
<point>4</point>
</data>
</series>
</chart>
Upon request:
<chart>
<categories>
<item>Apples</item> these two items must be populated from the database
<item>Pears</item>
</categories>
<series>
<name>John</name> this one also from database
<data>
<point>8</point> this is the data part, retrieved from database
<point>4</point>
<point>6</point>
<point>5</point>
</data>
</series>
</chart>
I want to create this type of xml structure using a java method or class where i retrieve all the information i need and then pass in into the xml file.

Anyways, am using xml to populate data for highcharts now.. Thanks for the answer

Related

How to add an attribute to a node in an already existing xml using java

I already have an xml which looks like the below one
<school>
<data>
<marks name="Peter"/>
<marks name="John"/>
</data>
</school>
I need to write a java code so that the xml is appended with an entry
<marks name="Dave"/>

Parse XML into Java Object List using simpleframework

I have an xml like shown. I want to convert this document into equivalent Java object shown below
<page>
<body>
<category id="category-0_2">
<container title="Spotlight" slug="spotlight"></container>
<container title="Just Added Shows" slug="just_added_shows"></container>
<container title="Originals" slug="originals"></container>
<container title="Popular TV Shows" slug="popular_tv_shows"></container>
<container title="Wonder Women" slug="wonder_women"></container>
</category>
</body>
</page>
public class HomeXML {
Page page;
Body body;
Category category;
List<Container> containerList;
}
Is it possible to do this using simpleframework xml serialiser? I can get the whole XML and parse it manually but I am looking for ways to do this via the simpleframework API.
Got the answer. simple framework provides utility functions which convert the XML document into Java object list.
More details here http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#util

Java Sax parse Unique XML tag File

I've read a lot about XML and SAX lately but I'm not sure nor have I seen this in any examples or seen it talked about. I have an XML file and I want to get the information from it.
<?xml version='1.0' encoding='UTF-8'?>
<eveapi version="2">
<currentTime>2015-04-30 04:22:22</currentTime>
<result>
<rowset name="characters" key="characterID"columns="name,characterID,corporationName,corporationID,allianceID,allianceName,factionID,factionName">
<row name="Grasume Crendraven" characterID="92916469" corporationName="Hyperion Guard" corporationID="98372642" allianceID="99005157" allianceName="Winmatar Republic" factionID="0" factionName="" />
<row name="Susan Snow" characterID="95325415" corporationName="Federal Navy Academy" corporationID="1000168" allianceID="0" allianceName="" factionID="0" factionName="" />
<row name="Grasume" characterID="95528725" corporationName="School of Applied Knowledge" corporationID="1000044" allianceID="0" allianceName="" factionID="0" factionName="" />
</rowset>
</result>
<cachedUntil>2015-04-30 05:02:33</cachedUntil>
</eveapi>
What I'm trying to do is get the information in the row name section then pull the info I need from that string. I assume the best thing for me to do is to pull the XML section I need and then set up a text parser to get the specific information that I need to be used in the rest of my program.

Best way to bind a XML File in Java (NetBeans)

i want to bind this simple XML File in my java project:
<?xml version="1.0" encoding="UTF-8"?>
<itg>
<reader>
<chapter id="1">
<subchapter id="1"></subchapter>
<subchapter id="2"></subchapter>
</chapter>
<chapter id="2">
<subchapter id="1"></subchapter>
<subchapter id="2"></subchapter>
</chapter>
<chapter id="3"></chapter>
</reader>
<questions>
</questions>
</itg>
I use NetBeans, and actually i bind the XML File by parsing the xml file into a ArrayList, an bind the list.
It works, but it is possible to bind the xml File in a better way?
Thanks!
For this small XML (and not only) I would recommend that you take a look at JAXB. The two basic operations are marshalling (converting Java objects to XML data) and unmarshalling (converting XML data to Java objects) but verification and so on is also provided.

What's the best way to read xml in android?

Hi I've an android app which uses an XML file to render its User Interface,And here is the xml
<?xml version="1.0" encoding="utf-8"?>
<questions>
<question id="1" label="Name" type="text"></question>
<question id="2" label="Gender" type="select" options="Male,Female,Transgender"></question>
<question id="3" label="Age" type="text"></question>
<question id="4" label="city" type="select" options="Banglore,Hyderabad,Chennai"></question>
</questions>
I am using DOM parser to read xml and I am getting the inputstream using url.openconnection().getInputstream() method.But I want the xml file to be included in my android project folder and use it.How would I go about that ?? so what are the other ways to get the InputStream ??
If you place the file in your assets folder, you can use the AssetManager to get an input stream to it.

Categories

Resources