skip To End XML Element in XMLStreamReader - Android XML

Android examples for XML:XML Element

Description

skip To End XML Element in XMLStreamReader

Demo Code


//package com.java2s;

import javax.xml.stream.*;

public class Main {
    public static void skipToEndElement(XMLStreamReader in)
            throws XMLStreamException {
        if (!in.isStartElement()) {
            return;
        }//  www  .  j a v  a  2 s  .  co  m

        int tagDepth = 1;
        while (tagDepth > 0 && in.hasNext()) {
            in.next();
            if (in.isStartElement()) {
                tagDepth++;
            } else if (in.isEndElement()) {
                tagDepth--;
            }
        }
    }
}

Related Tutorials