Code example for XmlPullParser

Methods: getText, next, nextTag

0
        } 
 
        // For text tags, extracts their text values. 
        protected String readText(XmlPullParser parser) throws IOException, XmlPullParserException {
            String result = "";
            if (parser.next() == XmlPullParser.TEXT) {
                result = parser.getText();
                parser.nextTag();
            } 
            return result;
        } 
 
        /* 
         * Skips tags the parser isn't interested in. Uses depth to handle 
         * nested tags. i.e., if the next tag after a START_TAG isn't a matching 
         * END_TAG, it keeps going until it finds the matching END_TAG (as 
         * indicated by the value of "depth" being 0). 
         */ 
        protected void skip(XmlPullParser parser) throws XmlPullParserException, IOException {
            if (parser.getEventType() != XmlPullParser.START_TAG) {
                throw new IllegalStateException();