This creates a DOM tree from the supplied XML
filename, and then serializes the tree to the
specified file.
File outputFile = new File(outputFilename);
DOMParser parser = new DOMParser();
// Get the DOM tree as a Document object
parser.parse(xmlDocument);
Document doc = parser.getDocument();
// Serialize
DOMSerializer serializer = new DOMSerializer();
serializer.serialize(doc, new File(outputFilename));