Overview

The DOM object representation is in the form of a tree structure, in which each node of the tree represents a component of the XML document. For example, consider the XML document (CarParts.xml) that describes car parts shown in Listing 5.1.

Listing 5.1. The CarParts.xml File
<?xml version='1.0' encoding='us-ascii'?>
<!--  XML file that describes car parts -->

<!DOCTYPE carparts SYSTEM "CarParts.dtd" ]>
<CarParts>
    <engine>
        Engine 1
    </engine>
    <carbody>
        CarBody 1
    </carbody>
    <wheel>
        Wheels 1
    </wheel>
    </carstereo>
</CarParts>

A graphical representation of the DOM for CarParts.xml is displayed in Figure 5.1.

Figure 5.1. Graphical representation of the DOM for the CarParts.xml file.

In the DOM, each entry in the XML file is a node. For each ...

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.