I place the local XML file into res/raw and then loads it into InputStreamer object. It works fine and I am able to parse its content.
When I place the same XML into res/xml, I get XmlPullParserException saying it can't find the START tag.
I use this code to fill InputStream object:
InputStream is = getResources().openRawResource(R.raw.data);
and this line to load the XML from /res/xml:
InputStream is = context.getResources().openRawResource(R.xml.data);
Why is this happening? If the 2nd approach is the wrong one, what is then the purpose of res/xml?
getXML()doesn't return anInputStreamso I'm not sure how your code compiles. It returns anXMLResourceParser.http://developer.android.com/reference/android/content/res/Resources.html#getXml(int)
The purpose of
/res/xmlis it's a handy place to store XML and later parse it! Sometimes you don't need anInputStream:)