Please visit our sponsors !
Introduction to the XML DOM
The XML Document Object Model (DOM) is a programming interface for
XML documents. It defines the
way an XML document can be accessed and manipulated.
Introduction
As a W3C specification, the objective for the
XML DOM has been to
provide a standard programming interface to a wide variety of applications. The XML DOM
is
designed to be used with any programming language and any operating system.
With the XML DOM, a programmer can create an XML document, navigate its structure, and
add, modify, or delete its elements.
The Node Interface
As you will see 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,
its information can be
retrieved and manipulated by accessing the 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 Model is used to access the individual elements in the
node
tree. As an example, the childNodes
property of the documentElement can be accessed with a for/each construct to enumerate
each individual node.
The Microsoft XML parser 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.
Most of the parser functions, demonstrated in this tutorial, are from
the W3C XML DOM
recommendation, apart from the document load and error functions. (Believe it or not: The
official DOM does not include standard functions for loading XML documents
!!)
The following table lists the most commonly used node types supported by the Microsoft XML
parser:
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 from this Web Site, you have to run Microsoft Internet
Explorer 5.0 or higher!
Jump to: Top of Page
or HOME or
Printer friendly page
Search W3Schools:
What Others Say About Us
Does the world know about us? Check out these places:
Dogpile
Alta Vista
MSN
Google
Excite
Lycos
Yahoo
Ask Jeeves
We Help You For Free. You Can Help Us!
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 1999-2002 by Refsnes Data. All Rights Reserved
|