Hosting Android Custom XML Files

I have a large XML file that looks like this:

<item><title>...</title><link>...</link></item>

How can I use parse(new InputSource()); to point to this xml file if it is stored in my project directory and where do I put the xml file?

+4
source share
1 answer

The best answer is ignoring your parse(new InputSource()) request parse(new InputSource()) . Put it in res/xml/ and use getResources().getXml() . This gives you XmlPullParser for your data. The big advantage here is that your XML is somewhat pre-parsed during the compilation phase, and therefore it is approximately 10 times faster during parsing than with regular XML parsers.

If you absolutely must use the DOM or SAX, put it in res/raw/ , then use getResources().openRawResource() to get an InputStream that you can wrap in an InputSource .

+6
source

All Articles