I have an XML file that is in the format below:
& lt; Query & gt; & Lt; Map & gt; & Lt; Value name = "val1" & gt; 1 & lt; / Value & gt; & Lt; Value name = "val2" & gt; 2 & lt; / Value & gt; & Lt; / Map & gt; & Lt; / Query & gt; & Lt; Quest & gt; & Lt; Map & gt; & Lt; Value name = "val1" & gt; 6 & lt; / Value & gt; & Lt; Value name = "val2" & gt; 8 & lt; / Value & gt; & Lt; / Map & gt; & Lt; / Quest & gt; When I write my sax parser, I get all values from start to finish, but I have to write a condition that will ask in a tag name, such as questions / queries and only get names and values for their specifications. I am not sure how to add this condition, after completing my status, there is no need to parse the remaining tags and my object is parsed.
Note : I am writing in java.
- Initially, check the element name with the given name, for example, if If you are looking for "query" and the name is "query", then some flag set to true.
- Element in the beginning, if the element's name is "value" and the flag is true, store name and value in a map.
- In the element, if the name of the element is equal to "query", then set the flag to the flag. Alternatively, turn off parsing completely.
Comments
Post a Comment