Here you can find the source of createXmlEventReaderOnXmlString(String xml, String docBaseUri)
static XMLEventReader createXmlEventReaderOnXmlString(String xml, String docBaseUri) throws XMLStreamException
//package com.java2s; //License from project: Open Source License import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLInputFactory; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import java.io.Reader; import java.io.StringReader; public class Main { static XMLEventReader createXmlEventReaderOnXmlString(String xml, String docBaseUri) throws XMLStreamException { Reader stringReader = new StringReader(xml); Source source = new StreamSource(stringReader, docBaseUri.toString());/*from w ww . j a v a 2s . co m*/ XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty("javax.xml.stream.isCoalescing", Boolean.TRUE); factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE); return factory.createXMLEventReader(source); } }