public static XMLStreamReader getXMLStreamReader(InputStream is) throws XMLStreamException, FactoryConfigurationError { //return XMLInputFactory.newInstance().createXMLStreamReader(is); return new StreamReaderDelegate(XMLInputFactory.newInstance().createXMLStreamReader(is)) { public int next() throws XMLStreamException { while (true) { int event = super.next(); switch (event) { case XMLStreamConstants.COMMENT: case XMLStreamConstants.PROCESSING_INSTRUCTION: continue; default: return event; } } } }; }