The JavaTM Web Services Tutorial
Home
TOC
Index
PREV TOP NEXT
Divider

Document Object Model

Eric Armstrong

In the SAX chapter, you wrote an XML file that contains slides for a presentation. You then used the SAX API to echo the XML to your display.

In this chapter, you'll use the Document Object Model (DOM) to build a small SlideShow application. You'll start by constructing a DOM and inspecting it, then see how to write a DOM as an XML structure, display it in a GUI, and manipulate the tree structure.

A Document Object Model is a garden-variety tree structure, where each node contains one of the components from an XML structure. The two most common types of nodes are element nodes and text nodes. Using DOM functions lets you create nodes, remove nodes, change their contents, and traverse the node hierarchy.

In this chapter, you'll parse an existing XML file to construct a DOM, display and inspect the DOM hierarchy, convert the DOM into a display-friendly JTree, and explore the syntax of namespaces. You'll also create a DOM from scratch, and see how to use some of the implementation-specific features in Sun's JAXP reference implementation to convert an existing data set to XML.

First though, we'll make sure that DOM is the most appropriate choice for your application. We'll do that in the next section, When to Use DOM.


Note: The examples in this chapter can be found in <JWSDP_HOME>/docs/tutorial/examples/jaxp/dom/samples.

In This Chapter
When to Use DOM
Reading XML Data into a DOM
Displaying a DOM Hierarchy
Examining the Structure of a DOM
Constructing a User-Friendly JTree from a DOM
Creating and Manipulating a DOM
Using Namespaces
Validating with XML Schema
Further Information
Divider
Home
TOC
Index
PREV TOP NEXT
Divider

This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.

All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.