1

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());
sandalone
  • 41,141
  • 63
  • 222
  • 338
  • 1
    It only says `Xml.newPullParser() had a bug[...]` so, `XmlPullParserFactory.newPullParser()` should be fine.. – Jave Apr 23 '12 at 09:51
  • @Jave Yes, but `nextText` is available to your object create via each way (factory and non-factory). – sandalone Apr 23 '12 at 10:24
  • 1
    Yes, they are both subclasses of the `XmlPullParser` interface, so they have a lot of method in common, although the implementation of these methods are different, so one of them (`ExpatPullParser`) had a bug that the other didn't have. – Jave Apr 23 '12 at 11:16

0 Answers0