Java tutorial
//package com.java2s; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; public class Main { /** * Static utility method that throws an exception if the supplied reader's * cursor doesn't point to a START_ELEMENT with the given name. * * @param reader The reader to test. * @param name The name of the element to require. * @throws XMLStreamException If the reader state is an element with the * specified name. */ public static final void requireElement(XMLStreamReader reader, QName name) throws XMLStreamException { reader.require(XMLStreamReader.START_ELEMENT, name.getNamespaceURI(), name.getLocalPart()); } }