Reputation: 6813
I am parsing an XML javax.xml, but i want to know whether a tag exist on a child node For example
<tag>
<child>
<special_tag>Special</special_tag>
<normal_tag>Normal</normal_tag>
</child>
<child>
<normal_tag>Normal</normal_tag>
</child>
</tag>
I am trying to know which Child has Special tag and which doesnt
Upvotes: 3
Views: 1061
Reputation: 115398
It seems that this is a classic usecase for SAX. You should register your listener and check the tag name. When it equals to special_tag get the element's parent.
Upvotes: 0
Reputation: 80192
Build the DOM for your xml and use XPath to query for the existence of "special_tag" using //special_tag
Upvotes: 0