Feb 10

A Transformer can be used to write a the XML for a DOM Document to a file. As the name implies a Transformer transforms a Source object into a Result, in this case the Source is the DOM Document, and the Result is an XML file.

TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Result result = new StreamResult(new File(xmlOutputFilePath));
Source source = new DOMSource(document);
transformer.transform(source, result);

written by objects \\ tags: , ,

Leave a Reply

You must be logged in to post a comment.