1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
TextView myXmlContent = (TextView)findViewById(R.id.my_xml);
String stringXmlContent;
// ***** BEGIN XML PARSING *****
try {
Resources res = this.getResources();
XmlResourceParser xrp = res.getXml(R.xml.myxml);
xrp.next();
int eventType = xrp.getEventType();
while (eventType != XmlResourceParser.END_DOCUMENT)
{
if (eventType == XmlResourceParser.START_DOCUMENT)
{
String s = xrp.getName();
System.out.println("START_DOCUMENT "+xrp.getText());
}
else if (eventType == XmlPullParser.START_TAG)
{
System.out.println("START_TAG "+xrp.getText());
String name = xrp.getName();
// Starts by looking for the entry tag
if (name.equals("entry")) {
} else {
// skip(parser);
}
// String s = xrp.getText();
// if (s.equals("F116")) {
//String encounterID = xrp.getAttributeResourceValue(null, "id", 0);
// String encounterType = xrp.getAttributeValue(null, "soustitre");
// }
}
else if (eventType == XmlPullParser.END_TAG)
// else if (eventType == XmlResourceParser.END_TAG)
{
String s = xrp.getText();
System.out.println("End TAG "+xrp.getText());
}
else if (eventType == XmlPullParser.TEXT)
// else if (eventType == XmlResourceParser.TEXT)
{
String s = xrp.getText();
System.out.println("Text "+xrp.getText());
}
eventType = xrp.next();
}
/*
if (xrp.getEventType() == XmlResourceParser.START_TAG) {
String s = xrp.getName();
if (s.equals("creature")) {
//String encounterID = xrp.getAttributeResourceValue(null, "id", 0);
String encounterType = xrp.getAttributeValue(null, "soustitre");
}
}
}
*/
}
catch (XmlPullParserException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// ***** END XML PARSING ***** |