File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes converting java to xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting java to xml" Watch "converting java to xml" New topic

converting java to xml

vaishali shah

Joined: Sep 27, 2009
Posts: 4
Hi ,
I have a list of object and using xstream i was able to convert the arraylist to xml. the resultant xml is as follows

But what i wanted was something like this.. <root><displayName "xyx" isBranch= true><displayName "abc" isBranch= false></displayName></displayName><displayName "efg" isBranch= false></displayName></root>.. I will probably have to make tags for this manually by iterating through the java list. i will need a recursive method for this probably the moment the list is created. Could some one help me with the recursive method so that the xml is generated as above coz i need to bind this to flex on the screen which requires the mentioned root format.

My java list creation is as follows

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Usually if you have one XML format and you want to systematically transform it to a different XML format, you will find that XSLT is a good way to do that.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10828

Welcome to the Ranch.

In future, while posting code, please UseCodeTags
I have edited your existing post. As you can see it is now much more easier to read and understand.
Also, please do check out

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: converting java to xml
It's not a secret anymore!