Chapter 12. Creating XML with Java

We now take a look at the one portion of manipulating XML that we have yet to address: creating and modifying XML. So far, all of our applications have used existing XML documents as constant data, never making changes to the original document. This is often the case in programming XML-based applications today; however, more and more leading edge technologies create XML documents in memory (such as XSP, which we looked at in Chapter 9). Other common applications that might need to modify XML data include XML editors and development environments as well as configuration managers, which we explore in this chapter.

In the last chapter, we created an XML configuration file for storing information related to configuring our XML-RPC classes. The assumption we made at that point was that changes to these configuration parameters would require a user (most likely a systems administrator) to edit the configuration file by hand and make modifications. Then (hopefully) the user would validate the modified XML document and restart the XML-RPC server and clients. However, this can be a very error-prone approach. First, it assumes that no mistakes are made when entering the new information. Second, it assumes that the user making the changes has the self-discipline to validate the modified XML document, ensuring correct and valid data has been entered. Even if both of these events occur every time modifications are made, which is unlikely in a real-world scenario, ...

Get Java and XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.