Here you can find the source of domToString(Node node, int estSize)
public static String domToString(Node node, int estSize) throws Exception
//package com.java2s; /*/*from w w w . j a v a 2 s .c o m*/ * Copyright (c) Jim Coles (jameskcoles@gmail.com) 2018 through present. * * Licensed under the following license agreement: * * http://www.apache.org/licenses/LICENSE-2.0 * * Also see the LICENSE file in the repository root directory. */ import org.w3c.dom.Node; import javax.xml.transform.Transformer; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.io.StringWriter; import java.io.Writer; public class Main { private static Transformer xtrans = null; public static String domToString(Node node, int estSize) throws Exception { String retVal = null; if (node != null) { StringWriter sw = new StringWriter(estSize); xtrans.transform(new DOMSource(node), new StreamResult(sw)); retVal = sw.toString(); sw.close(); } return retVal; } public static void domToString(Node node, Writer out) throws Exception { if (node != null) { xtrans.transform(new DOMSource(node), new StreamResult(out)); } return; } }