Search code examples
xmlsax

how to know the parent tag of a given tag when using SAXParser


Good morning,

I have the XML file example :

      <root>
          <node>
               <name n="one name"/>
          </node>
          <way>
               <name n="another name"/>
          </way>
      </root>

when I am parseing using SAX, and when I am raeding name tag, how can I know that I am in node tag or way tag. Are there any method to call or I just have to keep track of the state when parseing?

thank you


Solution

  • You have to keep track of the state when parsing.