I am using XMLPullParser for XML parsing and I want to use the XmlPullParser.FEATURE_PROCESS_DOCDECL function. This works fine on my Galaxy Nexus / JB, but on an emulator with Froyo I get an “unsupported function” exception.
The function is optional, but I would like to use it on phones that can. Is there a way to list the available functions on the current device or make the XmlPullParserFactory not crash if the function is not available and just ignore it?
Edit : the exact error appears here as well as my code
10-04 06: 45: 51.107: W / System.err (309): org.xmlpull.v1.XmlPullParserException: could not create a parser: org.kxml2.io.KXmlParser: org.xmlpull.v1.XmlPullParserException: unsupported function: 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): with 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
source share