How to Declare a new XmlPullParserFactory object

XmlPullParserFactory was added in API Level 1
This class is used to create implementations of XML Pull Parser defined in XMPULL V1 API. The name of actual factory class will be determined based on several parameters. It works similar to JAXP but tailored to work in J2ME environments (no access to system properties or file system) so name of parser class factory to use and its class used for loading (no class loader - on J2ME no access to context class loaders) must be passed explicitly. If no name of parser factory was passed (or is null) it will try to find name by searching in CLASSPATH for META-INF/services/org.xmlpull.v1.XmlPullParserFactory resource that should contain a comma separated list of class names of factories or parsers to try (in order from left to the right). If none found, it will throw an exception.

1. In the file, add the below line to the imports section.

import org.xmlpull.v1.XmlPullParserFactory;

2. Add the below line to the onCreate method. This will declare a new XmlPullParserFactory object named myXmlPullParserFactory

XmlPullParserFactory myXmlPullParserFactory;

3. Compile and run!

Next Recommended Article: How to Create a new Instance of XmlPullParserFactory