wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes XML and JTree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML and JTree" Watch "XML and JTree" New topic
Author

XML and JTree

Dhanya Palanisamy
Ranch Hand

Joined: Oct 20, 2006
Posts: 61
Hi Friends,

I have an XML which queries database for some data. I have to display this XML using JTree. Since data is huge it takes lot of time to build and display the tree. Is there anyway the child nodes would get build from XML after we click the corresponding parent node, as i wont be requring to view all child nodes. Pls do help.

Regards,
Dhanya
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You're asking for random access to XML documents and partial parsing. You aren't likely to find any XML parser that does that.

But you mentioned a database. It should be easy to do what you ask, if you get the data directly through JDBC. It's just the XML part that is getting in the way.
Dhanya Palanisamy
Ranch Hand

Joined: Oct 20, 2006
Posts: 61
Hi,

I found out we can do this by adding TreeExpansionListener to the JTree nodes. People who have prior experience with JTree and XML pls help. If someone gives me a sample code it will be really helpful
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yes, that's right. Similarly, I use a TreeWillExpandListener which gives you advance warning that you are supposed to load the child nodes. And if you already have the data available -- for example if you used a DOM parser and built a DOM that constructs an internal tree -- then you just get the child nodes from that tree and put them into the JTree.

But your original post implied you didn't want to build a DOM because of the size of the document. If that is still the case then looking for Swing solutions isn't going to help.
 
Consider Paul's rocket mass heater.
 
subject: XML and JTree
 
Similar Threads
JTree Node Display problem
jtree to jtable (need help in coding)
dynamic JTree
JTree
JTree and XML