Here you can find the source of domToString(Node domNode)
public static String domToString(Node domNode) throws TransformerException
//package com.java2s; /*//from w w w . ja va2s. c o m * SafeOnline project. * * Copyright 2006 Lin.k N.V. All rights reserved. * Lin.k N.V. proprietary/confidential. Use is subject to license terms. */ import java.io.*; import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Node; public class Main { public static String domToString(Node domNode) throws TransformerException { Source source = new DOMSource(domNode); StringWriter stringWriter = new StringWriter(); Result result = new StreamResult(stringWriter); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.transform(source, result); return stringWriter.toString(); } }