Android XmlPullParser Skip skipSubTree(XmlPullParser pp)

Here you can find the source of skipSubTree(XmlPullParser pp)

Description

Skip sub tree that is currently porser positioned on.

License

Open Source License

Declaration

public static void skipSubTree(XmlPullParser pp)
        throws XmlPullParserException, IOException 

Method Source Code

//package com.java2s;
// for license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/)

import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class Main {
    /**//from   w w  w  .ja v a  2 s.c o m
     * Skip sub tree that is currently porser positioned on.
     * <br>NOTE: parser must be on START_TAG and when funtion returns
     * parser will be positioned on corresponding END_TAG
     */
    public static void skipSubTree(XmlPullParser pp)
            throws XmlPullParserException, IOException {

        pp.require(XmlPullParser.START_TAG, null, null);
        int level = 1;
        while (level > 0) {
            int eventType = pp.next();
            if (eventType == XmlPullParser.END_TAG) {
                --level;
            } else if (eventType == XmlPullParser.START_TAG) {
                ++level;
            }
        }
    }
}

Related

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