how to parse xml files of text in a flip view in android app
hi i am trying to parse an XML file. My XML file looks as below
<Chapters>
<chapter>
<Question>abc</Question>
<answer>avksn</answer>
</chapter>
<chapter>
<Question>def</Question>
<answer>avksn</answer>
<image>a.png</image>
</chapter>
<chapter>
<Question>开发者_开发百科ccsv</Question>
<answer>avksn</answer>
<hint>acd</hint>
</chapter>
</Chapters>
I know to parse the XML file normally, my problem is i want to show the Questions one by one, ie only one question must be viewed at a time and i have placed a flip view. When the flip button is clicked the related answer must be viewed in the next page.
In some cases the other tags such as and must be viewed along with question tag. how to do this..... pls help me friends.....
Where do you store your xml file? I think it's better to use XmlPullParser, e.g.:
XmlPullParser parser = context.getResources().getXml(R.xml.data_file);
int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
String tagName = parser.getName();
...
}
eventType = parser.next();
}
If you store xml in assets - use AssetsManager to obtain XmlPullParser for it.
精彩评论