Reputation: 13
I have to parse a plist file in Android application. Plist is similar to xml given on following url:
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.
Upvotes: 0
Views: 1072
Reputation: 2173
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");
Upvotes: 1
Reputation: 34006
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
Upvotes: 0