Java tutorial
//package com.java2s; import java.io.StringWriter; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class Main { private static Transformer transformer; public static String domToText(Document inDocument) throws TransformerException { StringWriter output = new StringWriter(); DOMSource source = new DOMSource(inDocument); StreamResult result = new StreamResult(output); transformer.transform(source, result); //this.getWatcher().setProgressText("saved " + getEditedFile().getAbsolutePath()); return output.toString(); } }