Here you can find the source of domToString(Node node)
static String domToString(Node node)
//package com.java2s; //License from project: Open Source License import java.io.*; import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.*; public class Main { static String domToString(Node node) { try {//from w ww . j a v a 2 s. c om TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(node), new StreamResult(writer)); return writer.toString(); } catch (TransformerException te) { return "(TransformerException)"; } } }