You now know how to write Java programs that read XML. Let us now turn to the opposite process: producing XML output. Of course, you could write an XML file simply by making a sequence of
<) in the attribute values and text content.
A better approach is to build up a DOM tree with the contents of the document and then write out the tree contents. The following sections discuss the details.