• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

XML traversing problem

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm using JDOM for parsing the xml file.To traverse the file I have used for loop.
Is there any other parser which will give me the feature so that I dont have to traverse the file for searching the node.
for e.g

<bottombar>
<states>
<state name="main">
<sometag1>
<sometag2>
</state>
<state name="sub">
<sometag1>
<sometag2>
</state>
</states>
</bottombar>

as you can see the XML if I want to traverse the states children then I have to apply for loop so that I can get the required tag.
But I want a way by which if i gave "name" of the state then I should get that element.

thanks.


 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's what XPath is for. To use it, you don't need any extra library - it comes as part of the JRE in the javax.xml.xpath package. The XmlFaq links to a couple of XPath introductions.
 
reply
    Bookmark Topic Watch Topic
  • New Topic