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 how to show a XML tree in GUI? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to show a XML tree in GUI?" Watch "how to show a XML tree in GUI?" New topic
Author

how to show a XML tree in GUI?

marshall ma
Greenhorn

Joined: Aug 15, 2005
Posts: 6
Hi guys,

I have questions to consult you! I have a XML file and I want to have it showed in a GUI in a tree structure. The quesions are:

1. what kind of GUI i should use to show the xml tree structure, I think I should use JTree, right?

2. Is there any related code sample? I know there is sample on how to use trees (http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html ), but I don't know how to show xml file in a tree structure .

Thanks for the help!
[ September 12, 2005: Message edited by: marshall ma ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

You'll want to look at a DOM XML API like JDom which reads an XML file into a Tree like structure in memory. Once you have that putting that structure into a JTree is relatively easy.

After a bit of googling (which I hope you are doing) I found the following code on a JDom mailing list. I have not ran or tested this code in any way. So don't complain to me if it doesn't work for whatever reason. At the very least, it should get you going.



GenRocket - A Test Data Generation Platform
marshall ma
Greenhorn

Joined: Aug 15, 2005
Posts: 6
Hi Gregg Bolinger,

I use different parser from GLUE, still the code is helpful! And definitely your help will get me going. Thanks a lot for your kind help !!

Best Regards,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to show a XML tree in GUI?
 
Similar Threads
Develop UI displaying Tree Using XML
Reg :help in Archi Design
GUI: Contents Tree
Tree Structure
GUI representation (tree) to XML file?