code: public static void skipElement(final XMLStreamReader reader) throws XMLStreamException, IOException {
          if (reader.getEventType() != XMLStreamConstants.START_ELEMENT) {
              return;
          }
          final String namespace = reader.getNamespaceURI();
          final String name = reader.getLocalName();
          for (;;) {
              switch (reader.nextTag()) {
              case XMLStreamConstants.START_ELEMENT:
                  // call ourselves recursively if we encounter START_ELEMENT
                  skipElement(reader);
                  break;
              case XMLStreamConstants.END_ELEMENT:
              case XMLStreamConstants.END_DOCUMENT:
                  // discard events until we encounter matching END_ELEMENT
                  reader.require(XMLStreamConstants.END_ELEMENT, namespace, name);
                  reader.next();
                  return;
              }
          }
      }
docs: Method skipElement.
  
  @param reader
  XMLStreamReader
  @throws XMLStreamException
  if there is error skipping element
  @throws IOException
  if there is error skipping element