aspose 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
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: 15299
    
    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 - Experts at Building Test Data
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,
 
Consider Paul's rocket mass heater.
 
subject: how to show a XML tree in GUI?