Skip to content Skip to sidebar Skip to footer

Passing Xml Resource To Xmlreader

I am trying to pass a .xml file from my res folder to an XMLReader in order to parse it to an object: private void parseXML() { String parsedData = ''; try {

Solution 1:

InputStreaminStream= getResources().openRawResource(R.raw.questions);
xr.parse(inStream);

Solution 2:

getXml() returns an implementation of the XmlPullParser, and so it is already set to be parsed using that engine. Change your existing code to use XmlPullParser instead of SAX.

Solution 3:

I think you should put the file either in raw or asset folder to use SAX parser and then using context read that file from there

Android - Read file from Assets http://www.javacodegeeks.com/2012/02/android-read-file-from-assets.html

Post a Comment for "Passing Xml Resource To Xmlreader"