This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Convert JTree to XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic
Author

Convert JTree to XML

Bob Green
Ranch Hand

Joined: Feb 29, 2004
Posts: 93
I have an application using JTree and I would like to generate XML file from it. Each node in the JTree is an element in the XML file. What is the best approach to accomplish this task.
I greatly appreciate any ideas anyone can provide me.

Thanks!
Eric Snell
Greenhorn

Joined: Jun 09, 2004
Posts: 28

Originally posted by Bob Lou:
I have an application using JTree and I would like to generate XML file from it. Each node in the JTree is an element in the XML file. What is the best approach to accomplish this task.
I greatly appreciate any ideas anyone can provide me.

Thanks!


Maybe you can use something like XStream to write out your tree model. You also get the benefit that you can easily read back as a tree model object. You have some control over tags, but others would require much more work to customize.
Kranthi Poturaju
Greenhorn

Joined: Feb 25, 2010
Posts: 4

...
 
 
subject: Convert JTree to XML