Java tutorial
//package com.java2s; //License from project: Open Source License import javax.xml.stream.*; public class Main { public static void skipToEndElement(XMLStreamReader in) throws XMLStreamException { if (!in.isStartElement()) { return; } int tagDepth = 1; while (tagDepth > 0 && in.hasNext()) { in.next(); if (in.isStartElement()) { tagDepth++; } else if (in.isEndElement()) { tagDepth--; } } } }