There is no need for any External libraries, the JRE System libraries provide all you need.
I am infering that you have a org.w3c.dom.Document
object you would like to write to a file
To do that, you use a javax.xml.transform.Transformer
:
import org.w3c.dom.Document
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
public class XMLWriter {
public static void writeDocumentToFile(Document document, File file) {
// Make a transformer factory to create the Transformer
TransformerFactory tFactory = TransformerFactory.newInstance();
// Make the Transformer
Transformer transformer = tFactory.newTransformer();
// Mark the document as a DOM (XML) source
DOMSource source = new DOMSource(document);
// Say where we want the XML to go
StreamResult result = new StreamResult(file);
// Write the XML to file
transformer.transform(source, result);
}
}
Source: http://docs.oracle.com/javaee/1.4/tutorial/doc/JAXPXSLT4.html