views:

67

answers:

1

I'm having hard times 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 in implementing it. You can read about it here.

http://stackoverflow.com/questions/3583876/how-to-parse-different-xml-files-using-sax-on-android

I have ten different XML files.

Example:

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

<?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?

Appreciate your help!

+1  A: 

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

Blaise Doughan
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 Damiean