Here you can find the source of serializeSource(Source source)
public static String serializeSource(Source source)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; public class Main { public static String serializeSource(Source source) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try {/*w ww . j av a 2 s. c o m*/ TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); StreamResult dest = new StreamResult(baos); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.transform(source, dest); } catch (Exception e) { System.out.println("Error serializing node. " + e.getMessage()); } try { return baos.toString("UTF-8"); } catch (UnsupportedEncodingException e) { return baos.toString(); } } }