Search code examples
javaandroidxmlpullparser

Java Android - XmlPullParser - how can I start parsing from the beginning again?


I googled it and didn't find an answer - may be I didn't search it right.

My question is I'm parsing xml from the beginnning to the end of document - one way. What if somewhere in the middle I need to set parser to go to the Start of Document again?

I know only myXmlPullParser.next(); (or any other next) to move forward, but I need at some condition to start parsing from the beginning of document again. Is it possible?


Solution

  • Is it possible?

    Sure. Create a new pull parser instance, using the same code as you used to create the first one. Or, try calling setInput() on your existing instance, providing it a fresh copy of the data.