import org.w3c.dom.Document;
public class DOMToString {
public static String printXML(Document doc) {
OutputFormat outFormat = null;
outFormat = new OutputFormat();
outFormat.setEncoding("UTF-8");
outFormat.setVersion("1.0");
outFormat.setIndenting(true);
outFormat.setIndent(6);
return printXML(doc, outFormat);
}