Code example for XmlPullParser

Methods: getDepth, next

0
    public int next() throws XmlPullParserException, IOException { 
        if (!mStarted) {
            mStarted = true;
            return START_DOCUMENT;
        } 
        int ev = mParser.next();
 
        if (ev == END_TAG && mParser.getDepth() == 1) {
            // done with parser remove it from the context stack. 
            ensurePopped(); 
        } 
        mEventType = ev;
        return ev;
    } 
 
    public void require(int type, String namespace, String name)
            throws XmlPullParserException { 
        if (type != getEventType()
                || (namespace != null && !namespace.equals(getNamespace()))
                || (name != null && !name.equals(getName())))
            throw new XmlPullParserException("expected " + TYPES[type]