0

I have a XML Document like this:

...
<sometag>
    <subtag>
        <subsubtag someattr="foo" />
        <subsubtag someattr="bla" />
        <subsubtag someattr="bar" />
    </subtag>
</sometag>
...

i have it in an org.w3c.dom.Document and now need to get all subsubtag inside a subtag inside a sometag. Currently i query for all nodes that are a sometag, get all childs that are subtag, get all childs from here and so on... i cant query directly for all subsubtag because they can be listed on other places in the document too.

is there any faster way?

reox
  • 5,036
  • 11
  • 53
  • 98

1 Answers1

1

Use XPath for such complex query in XML files. It will be worth the effort of learning curve. Basically, in Xpath , you would just need to write

/sometag/subtag/subsubtag
Akhilesh Singh
  • 2,548
  • 1
  • 13
  • 10
  • ahh thanks, now i know how this is called: gives me instant answer here: http://stackoverflow.com/questions/2811001/how-to-read-xml-using-xpath-in-java – reox Mar 26 '13 at 21:01