permaculture playing cards*
The moose likes XML and Related Technologies and the fly likes XML traversing problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML traversing problem" Watch "XML traversing problem" New topic
Author

XML traversing problem

swapnel surade
Ranch Hand

Joined: Mar 05, 2009
Posts: 129
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.


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41129
    
  45
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.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML traversing problem
 
Similar Threads
Dynamic translation of XML into CSV using XSD
Spring 3.0 + REST Annotations
XML binding to <asp:dropdownlist> declaratively
Reset the collection content in bean:define
xsl in javascript