4

I'm using XMLPullParser to parse XML, and I want to use the XmlPullParser.FEATURE_PROCESS_DOCDECL feature. This works great on my Galaxy Nexus / JB, but on the emulator with Froyo, I get an "unsupported feature" exception.

The feature is not mandatory, but I would like to use it on phones who can. Is there a way to list the available features on the current device, or make the XmlPullParserFactory not crash if a feature is unavailable, and just ignore it ?

Edit : Here's the exact error I get, as well as my code

10-04 06:45:51.107: W/System.err(309): org.xmlpull.v1.XmlPullParserException: could not create parser: org.kxml2.io.KXmlParser: org.xmlpull.v1.XmlPullParserException: unsupported feature: http://xmlpull.org/v1/doc/features.html#process-docdecl (position:START_DOCUMENT null@0:0) ; 10-04 06:45:51.137: W/System.err(309): at org.xmlpull.v1.XmlPullParserFactory.newPullParser(XmlPullParserFactory.java:199)

XmlPullParserFactory factory;
XmlPullParser xpp;

factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setFeature(XmlPullParser.FEATURE_PROCESS_DOCDECL, true);
factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
xpp = factory.newPullParser(); // Exception is thrown here
XGouchet
  • 10,002
  • 10
  • 48
  • 83

0 Answers0