I have a xml file in the location res/xml/data.xml
I need to parse that xml file
XmlResourceParser xrp=context.getResources().getXml(R.xml.data);
I used this code to get that file. It returns as XmlResourceParser
Also tried with xmlpullparser
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
I am not getting clear idea between these two parser. My question is how to parse a xml file in the resource folder using xmlpullparser
?
XmlResourceParser
is aninterface
which extendsXmlPullParser
.getXml
wil return theXmlResourceParser
object. You can read the parser text similar to how we parse the input stream or a string usingXMLPullParser
Here is a sample code to parse from resource xml