Tutorial introduction
This tutorial is designed for developers who understand the basic concept of XML and are ready to move on to coding applications to manipulate XML using the Document Object Model (DOM). It assumes that you are familiar with concepts such as well-formedness and the tag-like nature of an XML document. (You can get a basic grounding in XML itself through the Introduction to XML tutorial, if necessary.)
All of the examples in this tutorial are in the Java language, but you can develop a thorough understanding of the DOM through this tutorial even if you don't try out the examples yourself. The concepts and API for coding an application that manipulates XML data in the DOM are the same for any language or platform, and no GUI programming is involved.
What is the Document Object Model?
The foundation of Extensible Markup Language, or XML, is the DOM. XML documents have a hierarchy of informational units called nodes; DOM is a way of describing those nodes and the relationships between them.
In addition to its role as a conceptual description of XML data, the DOM is a series of Recommendations maintained by the World Wide Web Consortium (W3C). The DOM began as a way for Web browsers to identify and manipulate elements on a page -- functionality that predates the W3C's involvement and is referred to as "DOM Level 0".
The actual DOM Recommendation, which is currently at Level 2 (with Level 3 in Last Call status as of this writing), is an API that defines the objects that are present in an XML document, as well as the methods and properties that are used to access and manipulate them.
This tutorial demonstrates the use of the DOM Core API as a means for reading and manipulating XML data using the example of a series of orders from a commerce system. It also teaches you how to create DOM objects in your own projects for storing or working with data.
The examples in this tutorial, should you decide to try them out, require the following tools to be installed and working correctly. Running the examples is not a requirement for understanding.
- A text editor: XML files are simply text. To create and read them, a text editor is all you need.
- Java™ 2 SDK, Standard Edition version 1.4.x: DOM support has been built into the latest version of Java technology (available at http://java.sun.com/j2se/1.4.2/download.html), so you won't need to install any separate classes. (If you're using an earlier version of the Java language, such as Java 1.3.x, you'll also need an XML parser such as the Apache project's Xerces-Java (available at http://xml.apache.org/xerces2-j/index.html), or Sun's Java API for XML Parsing (JAXP), part of the Java Web Services Developer Pack (available at http://java.sun.com/webservices/downloads/webservicespack.html).
- Other Languages: Should you wish to adapt the examples, DOM implementations are also available in other programming languages. You can download C++ and Perl implementations of the Xerces parser from the Apache Project at http://xml.apache.org.



