Reputation: 2119
In my project parse plist from sdcard.
I have done one example that takes a xml file from resource belove code.
Resources res = activity.getResources();
XmlResourceParser xpp = res.getXml(R.xml.myplist);
but i want to
XmlResourceParser xpp = (SDCARD xml file)
Please ,Help me .
Upvotes: 0
Views: 440
Reputation: 46963
You should substitute the XmlResourceParser
with XmlPullParser
. The first one is for parsing xml from resources folder, the latter - for parsing xml from InputStream
. From then on you need to construct an InputStream
from the sdcard:
File file = new File (path-to-your-file);
fileInputStream fis = new FileInputStream(file);
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(fis, "UTF-8");// or whatever encoding suites you
EDIT: BTW I am interested in the way you implemented to parse plist in android.
Upvotes: 1
Reputation: 3192
Just use the java file command for your xml file on sdcard.
File file=new File("/mnt/sdcard/example.xml");
and using DOM or SAX parser you can parse the data(information) from it for your application.
Thnx.
EDIT: parsing local xml file using Sax in android, Read XML Resources in Android, using XmlResourceParser: XML parsing interface or Here or Here Look at these tutorials.
Upvotes: 0