Code example for XmlPullParser

Methods: getTextnextnextTag

0
    } 
 
    // For the tags title and summary, extracts their text values. 
    private 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). 
    private void skip(XmlPullParser parser) throws XmlPullParserException, IOException {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            throw new IllegalStateException();
        } 
        int depth = 1;
        while (depth != 0) {