Introduction to XML Document Object Model
(Page 1 of 5 )
Learn about XML and the hierarchical structure of the Document Object Model in this down and dirty piece! Nodes, NodeLists, NameNodeMaps, as well as properties such as parentNodes, childNodes, nodeNames, and nodeValues are explored, explained and code is given.
"In order to represent the hierarchical nature of XML, the DOM provides a whole set of objects, methods and properties that allow us to manipulate the DOM. We will not be able to cover them all in this tutorial, but we’ll cover a few to give you the essence of the sort of things you can achieve."
The Document Object Model is an API for HTML and XML documents. It defines the logical structure of the documents, and the way they can be accessed. DOM gains its importance because it defines a standard way in which you can access and manipulate the XML structure. In short we can say DOM is a programming interface for XML documents and also defines the way an XML document can be accessed and manipulated. A simple illustration will help us understand about the XML document, and how the DOM can be used.
Example 1
<BookAuthors>
<Author>
<au_id>1001</au_id>
<au_lname> Gates </au_name>
<au_fname> Bill </au_name>
</Author>
<Author>
<au_id>1002</au_id>
<au_lname> Potter</au_name>
<au_fname> Harry </au_name>
</Author>
</BookAuthors>
If you take a closer look you will be able to see that XML documents are always hierarchical in nature, which means they always have a top-level or root element and then child elements. So the above document could be represented as:

The tree would have been deeper, if there were more children. In DOM terms these elements are also called nodes. A node just represents a generic element in this tree-type structure.
Next: Covering Our Base >>
More XML Articles
More By Gayathri Gokul