Back to project page android_tutorial_projects.
The source code is released under:
Copyright (c) 2013, Uthcode All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redi...
If you think the Android project android_tutorial_projects listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.uthcode; /* www .j a v a 2 s . co m*/ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; import java.io.IOException; import java.io.StringReader; public class Main { public static void main(String[] args) throws XmlPullParserException, IOException { XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(new StringReader("<foo>Hello World</foo>")); int eventType = xpp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_DOCUMENT) { System.out.println("Start Document "); } else if (eventType == XmlPullParser.END_DOCUMENT) { System.out.println("End Document "); } else if (eventType == XmlPullParser.START_TAG) { System.out.println("Start Tag " + xpp.getName()); } 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(); } } }