Here you can find the source of document2String(Node document)
static public String document2String(Node document)
//package com.java2s; //License from project: Apache License import java.io.StringWriter; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Node; public class Main { /**/*from w w w. java2 s . c o m*/ * XSL transform (identity) to create text from Document. */ static private Transformer identityTransformer; static public String document2String(Node document) { if (document == null) return null; StringWriter stringWriter = new StringWriter(); try { identityTransformer.transform(new DOMSource(document), new StreamResult(stringWriter)); } catch (TransformerException e) { e.printStackTrace(); } return stringWriter.toString(); } }