Java tutorial
//package com.java2s; import java.io.StringWriter; 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.Document; public class Main { public static String Doc2String(Document paramDocument) { try { DOMSource localDOMSource = new DOMSource(paramDocument); StringWriter localStringWriter = new StringWriter(); StreamResult localStreamResult = new StreamResult(localStringWriter); TransformerFactory localTransformerFactory = TransformerFactory.newInstance(); Transformer localTransformer = localTransformerFactory.newTransformer(); localTransformer.transform(localDOMSource, localStreamResult); return localStringWriter.toString(); } catch (Exception localException) { localException.printStackTrace(); } return null; } }