This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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 Elasticsearch in Action this week in the Big Data 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

how to show a XML tree in GUI?

marshall ma

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 ( ), 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: 15302

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

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:
subject: how to show a XML tree in GUI?