3

I'm having a hard time parsing multiple different XML files on Android using the built-in SAX parser.

Nate and Aron Saunders have helped me with the right approach to this problem but I struggle with implementing it. You can read about it here.

I have ten different XML files.

Example ResponseOne.

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

Example ResponseTwo.

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

And so on. Every root tag is different. Now I know that I could branch the parser to trigger a different event on every root tag but I'm not quite sure I know how exactly do achieve this.

How would I tell my SAX handler that he should parse for AnotherInnerTag with its attributes based on the root tag?

Community
  • 1
  • 1
Octavian Helm
  • 39,405
  • 19
  • 98
  • 102

1 Answers1

1

Assuming the Android SAX parser is similar to the Java SE SAX parser the following strategy could be used:

Community
  • 1
  • 1
bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • 1
    Thanks. I'm always amused by the fact that all those answers were on StackOverflow and I couldn't find them even after hours of search. – Octavian Helm Sep 01 '10 at 15:58