Android XmlPullParser Skip skipTag(XmlPullParser parser)

Here you can find the source of skipTag(XmlPullParser parser)

Description

skip Tag

Declaration

public static void skipTag(XmlPullParser parser)
            throws XmlPullParserException, IOException 

Method Source Code

//package com.java2s;
import java.io.IOException;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class Main {
    public static void skipTag(XmlPullParser parser)
            throws XmlPullParserException, IOException {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            throw new IllegalStateException();
        }// w w  w.j  a  v  a  2s  .  c  om

        int depth = 1;
        while (depth != 0) {
            switch (parser.next()) {
            case XmlPullParser.END_DOCUMENT:
                throw new XmlPullParserException(
                        "reached unexpected end of document");
            case XmlPullParser.END_TAG:
                depth--;
                break;
            case XmlPullParser.START_TAG:
                depth++;
                break;
            }
        }
    }
}

Related

  1. skipExit(final XmlPullParser pp)
  2. skipExit(final XmlPullParser pp, final String tagName)
  3. skipSubTree(XmlPullParser pp)
  4. skipSubTree(XmlPullParser pp)
  5. skipSubTree(final XmlPullParser pp)
  6. skipWhitespace(final XmlPullParser pp)
  7. requireSkip(final XmlPullParser pp, final String tagName)