I have an xml which comes in form like below
<brick type="Func" gid="29" fname="removeContexts" fns="dflt">
<viewData x="470" y="45"/>
<arg>
<brick type="Func" gid="4" fname="useOneAsMany" fns="dflt" object_uid="r1">
<viewData x="335" y="91"/>
<arg>
<brick type="Src" gid="0" path="/OrderCreate/Header/To/PartnerInformation/PartnerIdentifier">
<viewData x="219" y="29"/>
</brick>
</arg>
<arg pin="1">
<brick type="Func" gid="3" fname="concat" fns="dflt">
<viewData x="190" y="80"/>
<arg>
<brick type="Func" gid="13" fname="const" fns="dflt" object_uid="r0">
<viewData x="50" y="83"/>
<bindings>
<param name="value">
<value>ALL</value>
</param>
</bindings>
</brick>
</arg>
<arg pin="1">
<brick object_uid="r0"/>
</arg>
<bindings>
<param name="delimeter">
<value/>
</param>
</bindings>
</brick>
</arg>
<arg pin="2">
<brick type="Func" gid="23" fname="const" fns="dflt">
<viewData x="190" y="137"/>
<bindings>
<param name="value">
<value>-other-</value>
</param>
</bindings>
</brick>
</arg>
</brick>
</arg>
</brick>
As you see we have multiple tags with same name to any depth. In start element, I check for something. How do I know that the corresponding end element has been called using a SAX Parser?
For e.g when I get I start a counter and I want to end the counter when I get its corresponding and not another .
If with DOM too any idea how to use or what to do?
Probably you want to use a stack.
When you detect a start tag, push something appropriate onto the stack, and when you detect an end tag, pop the stack.
Then when you get an end tag, the top of the stack will always contain what was put there by the corresponding start tag, and besides popping it so that the alignment continues to be correct, you can also do something appropriate with it.