Hii every one, am brand new to android,i have a doubt can any one help me
In this following link
http://www.androidpeople.com/android-xml-parsing-tutorial-using
In Android you can store data in the assets folder, which can be entered by your code. To address your file use
file:///android_asset/yourFile.xml
I haven´t tried this yet, but I hope it will work
In the link you provided, replace the line 47
xr.parse(new InputSource(sourceUrl.openStream()));
with
xr.parse(getResources().getAssets().open(fileName));
and place your xml file in /res/raw folder
links: Asset Manager Docs and Resources Manager Docs
try {
// InputStream is = getResources().getAssets().open("yourfilename.xml");
InputStream is =getAssets().open("yourfilename.xml");
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
MyXMLHandler myXMLHandler = new MyXMLHandler();
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(is));
} catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
This is what I did,
InputStream is = res.openRawResource(R.raw.fileName);
xr.parse(new InputSource(is));