Advertise Here
Need an introduction to XML Document Object Models? Learn about document object model parsing, how to parse XML document objects using Microsoft XML, how to find DOM parser errors, and how to test for valid XML display errors in documents. - ?
Extensible Markup Language

Search XML Files

XML Files RSS Feed XML Files Updates

 


The XML DOM

by Jan Egil Refsnes

prev next

The Document Object Model

The DOM is a programming interface for HTML and XML documents. It defines the way a document can be accessed and manipulated. 

Using a DOM, a programmer can create a document, navigate its structure, and add, modify, or delete its elements.

As a W3C specification, one important objective for the DOM has been to provide a standard programming interface that can be used in a wide variety of environments and applications.

The W3C DOM has been designed to be used with any programming language.


The Node Interface

As you will se in the next section, a program called an XML parser can be used to load an XML document into the memory of your computer. When the document is loaded, it's information can be retrieved and manipulated by accessing the Document Object Model (DOM).

The DOM represents a tree view of the XML document. The documentElement is the top-level of the tree. This element has one or many childNodes that represent the branches of the tree.

A Node Interface is used to read and write (or access if you like) the individual elements in the XML node tree. The childNodes property of the documentElement can be accesses with a for/each construct to enumerate each individual node.

The Microsoft XML parser used to demonstrate the DOM in this Web, supports all the necessary functions to traverse the node tree, access the nodes and their attribute values, insert and delete nodes, and convert the node tree back to XML.

All the demonstrated Microsoft XML parser functions are from the official W3C XML DOM recommendation, apart from the load and loadXML functions. (Believe it or not: The official DOM does not include standard functions for loading XML documents !!)

A total of 13 node types are currently supported by the Microsoft XML parser. The following table lists the most commonly used node types:

Node Type Example
Document type <!DOCTYPE food SYSTEM "food.dtd">
Processing instruction <?xml version="1.0"?>
Element <drink type="beer">Carlsberg</drink>
Attribute type="beer"
Text Carlsberg

To view the examples in this Web, you have to use Microsoft Internet Explorer 5.0 !


prev next

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 DevX XML Content 
- W3C Has a New XML Standard: XProc
- The Key XForms Enhancements in Version 1.1
- Performing Hierarchical Restructuring Using ANSI SQL
- Taking XML Validation to the Next Level: Explore CAM's Expressive Power
- Taking XML Validation to the Next Level: Introducing CAM

Jump to : Top Of Page or HOME