I have a large XML file which is arranged like so:
<item><title>...</title><link>...</link></item>
How can I use parse(new InputSource());
to point to this XML file if it's stored within my project directory and where do I put the XML file?
I have a large XML file which is arranged like so:
<item><title>...</title><link>...</link></item>
How can I use parse(new InputSource());
to point to this XML file if it's stored within my project directory and where do I put the XML file?
The best answer ignores your parse(new InputSource())
request. Put it in res/xml/
and use getResources().getXml()
. This gives you an XmlPullParser
on your data. The big advantage here is that your XML is somewhat pre-parsed during the compile step, and so parsing is about ten times faster at runtime than with normal XML parsers.
If it absolutely positively has to use DOM or SAX, put it in res/raw/
, then use getResources().openRawResource()
to get an InputStream
, which you can wrap in an InputSource
.