File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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

...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert JTree to XML