Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Java + Generating XML structure from give List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java + Generating XML structure from give List" Watch "Java + Generating XML structure from give List" New topic
Author

Java + Generating XML structure from give List

Info Wwn
Greenhorn

Joined: Dec 22, 2009
Posts: 2
I have a List in the structure mentioned below (its a List of HashMaps)

{TeamName=India, Name=Sachin, Score=170}
{TeamName=India, Name=Sehwag, Score=120}
{TeamName=Sri-Lanka, Name=Sangakara, Score=20}
{TeamName=Sri-Lanka, Name=Murali, Score=20}
{TeamName=Sri-Lanka, Name=Jayasurya, Score=70}

I need to generate the following XML structure

<node id="1" label="India" >
<node id="1.1" label="Sachin" Score="170" />
<node id="1.2" label="Sehwag" Score="120" />
</node>
<node id="2" label="Sri-Lanka">
<node id="2.1" label="Sangakara" Score="20" />
<node id="2.2" label="Murali" Score="20" />
<node id="2.3" label="Jayasurya" Score="70" />
</node>

How can I do this?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You can do it via any of several third-party serialization libraries, or just do it "by hand" and create the string yourself.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java + Generating XML structure from give List
 
Similar Threads
"Out of resource" Error in the exam!
India Won the Worldcup 2011
Cricket world cup 2011
WA #1.....word association
Well - Done Murali....