I have to parse a plist file in Android application. Plist is similar to xml given on following url:
http://pastie.org/2583229
Will I be able to parse to display data 开发者_开发问答in the app? Which parser is good for this purpose? Please help me here by giving me some suggestions.
Below I have mentioned one way of parsing that XML. I have used XmlPullParser to parse the above mentioned xml:
String str1 ="<Xml to be parsed>";
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput( new StringReader (str1));
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
String str;
if(eventType == XmlPullParser.START_DOCUMENT) {
System.out.println("Start document");
} else if(eventType == XmlPullParser.START_TAG) {
str = xpp.getName();
System.out.println("Start tag "+str);
} else if(eventType == XmlPullParser.END_TAG) {
System.out.println("End tag "+xpp.getName());
} else if(eventType == XmlPullParser.TEXT) {
System.out.println("Text "+xpp.getText());
}
eventType = xpp.next();
}
System.out.println("End document");
Your response is xml file so you can read that file using any xml parser
For more details about different types of xml parser follow below link
Different types of xml parsers
精彩评论