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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The best answer ignores your
parse(new InputSource())request. Put it inres/xml/and usegetResources().getXml(). This gives you anXmlPullParseron 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 usegetResources().openRawResource()to get anInputStream, which you can wrap in anInputSource.