try {
XMLInputFactory factory = XMLInputFactory.newInstance();
// factory.setProperty("http://java.sun.com/xml/stream/properties/report-cdata-event", Boolean.TRUE);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlString.getBytes());
StAXOMBuilder staxOMBuilder = OMXMLBuilderFactory.
createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
factory.createXMLStreamReader(byteArrayInputStream));
staxOMBuilder.setDoDebug(true);
OMElement rootElement = staxOMBuilder.getDocumentElement();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OMOutputImpl omOutput = new OMOutputImpl(baos, false);
omOutput.ignoreXMLDeclaration(ignoreXMLDeclaration);