Writing Out a DOM as an XML File
After you have constructed a DOM—either by parsing an XML file or building it programmatically—you frequently want to save it as XML. This section shows you how to do that using the Xalan transform package.
Using that package, you'll create a transformer object to wire a DOMSource to a StreamResult. You'll then invoke the transformer's transform() method to write out the DOM as XML data.
Reading the XML
The first step is to create a DOM in memory by parsing an XML file. By now, you should be getting comfortable with the process.
The code discussed in this section is in TransformationApp01.java.
The following code provides a basic template to start from. (It should be familiar. It's basically the same code ...