• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML and JTree

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic