This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to show a XML tree in GUI?

 
marshall ma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
marshall ma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic