How to Create a new Instance of XmlPullParserFactory

public static XmlPullParserFactory newInstance () was Added in API level 1
Create a new instance of a PullParserFactory that can be used to create XML pull parsers
Returns - a new instance of a PullParserFactory, as returned by newInstance (null, null);
Throws: XmlPullParserException

1. Declare a new XmlPullParserFactory object
2. In the MainActivity.java file, add the below line to the imports section.

import import org.xmlpull.v1.XmlPullParserException;


3. Add the below line to the onCreate method. This create a new instance of XmlPullParserFactory and set it to myXmlPullParserFactory

try {
        myXmlPullParserFactory = XmlPullParserFactory.newInstance();
} catch (XmlPullParserException e) { 
e.printStackTrace();
        //Toast.makeText(this, "XmlPullParserException", Toast.LENGTH_LONG).show();
}

4. Compile and run!

Next Recommended Article: How to Have XmlPullParserFactory Provide Support for XML Namesspaces

Resources:
http://developer.android.com/reference/org/xmlpull/v1/XmlPullParserFactory.html#newInstance()