Here you can find the source of moveReaderToEndCurrentTag(XMLStreamReader reader)
Parameter | Description |
---|---|
reader | XMLStreamReader which should be moved |
Parameter | Description |
---|---|
XMLStreamException | when parse exception occurs |
public static void moveReaderToEndCurrentTag(XMLStreamReader reader) throws XMLStreamException
//package com.java2s; // License: GPL. For details, see LICENSE file. import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; public class Main { /**/* w w w .j a va2 s. c om*/ * Moves the reader to the closing tag of current tag. * @param reader XMLStreamReader which should be moved * @throws XMLStreamException when parse exception occurs */ public static void moveReaderToEndCurrentTag(XMLStreamReader reader) throws XMLStreamException { int level = 0; QName tag = reader.getName(); for (int event = reader.getEventType(); reader.hasNext(); event = reader.next()) { if (XMLStreamReader.START_ELEMENT == event) { level += 1; } else if (XMLStreamReader.END_ELEMENT == event) { level -= 1; if (level == 0 && tag.equals(reader.getName())) { return; } } if (level < 0) { throw new IllegalStateException( "WMTS Parser error - moveReaderToEndCurrentTag failed to find closing tag"); } } throw new IllegalStateException("WMTS Parser error - moveReaderToEndCurrentTag failed to find closing tag"); } }