Reputation: 1461
I'm having an xml file in the below format:
<Query>
<map>
<value name="val1">1</value>
<value name="val2">2</value>
</map>
</Query>
<Quest>
<map>
<value name="val1">6</value>
<value name="val2">8</value>
</map>
</Quest>
When I write my SAX parser, I get all the values from start to end, but I need to write a condition what would take in a tag name, like Query / Quest and get only the name and value for their specific.
I'm not sure how to add this condition, I don't need to parse the rest of the tags once my condition is met and my object is parsed.
NOTE: I'm writing in Java.
Upvotes: 1
Views: 283
Reputation: 32720
If you only want the data for a particular set of elements then a DOM based parser especially one with XPath to get the required fields might be easier.
An xpath library is jaxen which can be used with several doms I have used JDOM
Upvotes: 0
Reputation: 75679
Upvotes: 2