Managing Data Using DOM

So far, you have learned how to access data from a DOM. The advantage that DOM provides over SAX is that you can add, modify, or delete different nodes, such as the element, comments, and so on, at any location in the DOM tree. Next, you will learn how to manipulate the DOM by adding elements, attributes, and element texts, and also how to delete a node and normalize a DOM after it has been modified. This is useful in many ways. By manipulating a DOM, you can create your own XML data from an existing document. Other uses include the capability to extract partial information from a DOM, or extracting data from a DOM based on the relationship between nodes.

One important point to remember is that while DOM provides the capability ...

Get Java™ APIs for XML Kick Start 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.