Here you can find the source of asString(XMLStreamReader xmlr)
public static String asString(XMLStreamReader xmlr) throws Exception
//package com.java2s; //License from project: Apache License import java.io.StringWriter; import javax.xml.stream.XMLStreamReader; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamResult; public class Main { public static String asString(XMLStreamReader xmlr) throws Exception { Transformer transformer = TransformerFactory.newInstance() .newTransformer();// w ww .j a va2 s . co m StringWriter stringWriter = new StringWriter(); transformer.transform(new StAXSource(xmlr), new StreamResult( stringWriter)); return stringWriter.toString(); } }