Here you can find the source of render(final Node node)
public static String render(final Node node)
//package com.java2s; //License from project: Apache License import java.io.StringWriter; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Node; public class Main { public static String render(final Node node) { try {// w w w . j av a 2 s .com final StringWriter writer = new StringWriter(); final DOMSource domSource = new DOMSource(node); final StreamResult streamResult = new StreamResult(writer); final TransformerFactory tf = TransformerFactory.newInstance(); final Transformer serializer = tf.newTransformer(); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.transform(domSource, streamResult); return writer.toString(); } catch (final Exception e) { throw new RuntimeException("Error serializing DOM", e); } } }