Skip to main content


developerWorks  >  XML  >

Understanding DOM

developerWorks

Level: Introductory

Nicholas Chase (nicholas@nicholaschase.com), Author, Web site developer

29 Jul 2003
Updated 12 Mar 2007

Register now or sign in using your IBM ID and password.

Even before there was XML, there was the Document Object Model, or DOM. It allows a developer to refer to, retrieve, and change items within an XML structure, and is essential to working with XML. In this tutorial, you will learn about the structure of a DOM document. You will also learn how to use Java technology to create a Document from an XML file, make changes to it, and retrieve the output.

Prerequisites

The tutorial assumes that you are familiar with concepts such as well-formedness and the tag-like nature of an XML document.

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 the DOM are the same for any language or platform, and no GUI programming is involved.


System requirements

You'll need JavaScript enabled in your browser.

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.
  • JavaTM 2 SDK, Standard Edition version 1.4.x with built-in SAX support (available at ttp://java.sun.com/j2se/1.4.2/download.html. If you use an earlier version of Java, such as Java 1.3.x, you 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: If you wish to adapt the examples, DOM implementations are also available in other programming languages. Download C++ and Perl implementations of the Xerces parser from the Apache Project at http://xml.apache.org.


Duration

Under one hour


Formats

html, pdf


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!


Back to top


Document options

Document options requiring JavaScript are not displayed