How to break a SAX parser depending on the first known tag?

I find it difficult to parse several different XML files on Android using the built-in SAX parser.

Nate and Aron Saunders helped me with the right approach to this problem, but I am struggling with its implementation. You can read about it here .

I have ten different XML files.

An example ResponseOne.

<?xml version="1.0" encoding="UTF-8"?>
<ResponseOne>
  <InnerTag Id="1">
  </InnerTag>
</ResponseOne>

An example ResponseTwo.

<?xml version="1.0" encoding="UTF-8"?>
<ResponseTwo>
  <AnotherInnerTag State="2">
  </AnotherInnerTag>
</ResponseTwo>

Etc. Each root tag is different. Now I know that I can deploy the parser to trigger another event on each root tag, but I'm not quite sure I know how to achieve this.

How can I tell the SAX handler what it should parse AnotherInnerTagwith its attributes based on the root tag?

+3
1

, Android SAX Java SE SAX, :

+1

Source: https://habr.com/ru/post/1762422/


All Articles