Reputation: 29
I have an xml file which is stored locally in my app and I want to show parsed data from it in web-view.
Upvotes: 1
Views: 864
Reputation: 4533
To access XML resources stored in res/xml, call getResources().getXml() from any Activity or other Context. You need to supply to getXml() the ID of the XML to load (R.xml.myfile).
to read your xml add code as shown below
XmlResourceParser myxml = mContext.getResources().getXml(R.xml.MyXml);
//MyXml.xml is name of our xml in newly created xml folder, mContext is the current context
// Alternatively use: XmlResourceParser myxml = getContext().getResources().getXml(R.xml.MyXml);
myxml.next();//Get next parse event
int eventType = myxml.getEventType(); //Get current xml event i.e., START_DOCUMENT etc.
and to get content of code add code shown below
Upvotes: 1
Reputation: 7302
We need more information regarding what exactly you want to do. It is very unclear. There are two things that you could mean:
In the former case, it is pretty straightforward. If it is the latter, check out this answer: How can I transform xml to html on android?
Upvotes: 2