Android 2.3.3 and XmlPullParser.nextText()

918 Views Asked by At

Article on this link (android developer's blog) says:

Using XmlPullParser is an efficient and maintainable way to parse XML on Android. Historically Android has had two implementations of this interface:

- KXmlParser, via XmlPullParserFactory.newPullParser().
- ExpatPullParser, via Xml.newPullParser().

The implementation from Xml.newPullParser() had a bug where calls to nextText() didn’t always advance to the END_TAG as the documentation promised it would. As a consequence, some apps may be working around the bug with extra calls to next() or nextTag():
...

I do not understand if this refers to XmlPullParserFactory.newPullParser() or Xml.newPullParser() or to both.

For example, will this code on Android 2.3.3 and lower create a bug:

XmlPullParser xpp = XmlPullParserFactory.newInstance().newPullParser();
int event = xpp.getEventType();
while (...event not end doc and tag not equal search term...){
     event = xpp.next();
}
myClass.setSomeText(xpp.nextText());
0

There are 0 best solutions below