Displaying the DOM

As described in Chapter 3, "The Document Object Model (DOM)," the DOM represents an XML document as a hierarchical data structure or tree. The Java Platform Standard Edition (SE) includes support for a graphical tree view in the Swing package (javax.swing ) called a JTree . The JTree component renders a tree model. Our job will be to encapsulate the DOM data model inside a Swing tree model so that it can be rendered as a JTree . The result of this is presented in Figure 7.1.

Figure 7.1. A DOM rendered with a JTree.

The DOM represents an XML document in two ways—a flat representation in which every member of the tree is a node ...

Get XML Development with Java™ 2 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.