Code example for XmlPullParser

Methods: getTextnextnextTag

    // For the tags title and summary, extracts their text values. 
    private String readText(XmlPullParser parser) throws IOException, XmlPullParserException {
        String result = "";
        if ( == XmlPullParser.TEXT) {
            result = parser.getText();
        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;