DOM or Document Object Model is a W3C standard for accessing documents like XML and HTML. DOM represents documents in a tree structure and defines standard for accessing and manipulating XML documents. XML DOM is a standard model for accessing, adding, deleting elements in XML documents. It is platform and language independent.

XML DOM defines objects and properties of XML document called elements and interfaces to access them. The elements define characteristics of a class. Interface or methods defined in the DOM manipulate the element.

Example of tree structure of the XML DOM

Tree structure of the XML DOM

<?xml version="1.0"?>

<!DOCTYPE earth SYSTEM "earthArea.dtd">

<earth totalArea="100">

      <!-- Area given below is in percentage -->

      <country>Russia</country>

      <capital>Moscow</capital>

      <area>11.5</area>

      <country>USA</country>

      <capital>Washington</capital>

      <area>6.5</area>

      <country>India</country>

      <capital>Delhi</capital>

      <area>2.3</area>

</earth>

XML Document Object Model description

The element node, text node, comment node …etc come under root element.  The element at the top of a node is the parent node. Parent node is said to have children nodes. Children at same level are calledsiblings. A node can have only one parent and any number of siblings. 

DOM specification defined by W3C is done in various levels. In DOM Level 1 specifications, XML and HTML documents are focused. In DOM level 2, stylesheets are supported and style information can be manipulated programmatically. DOM level 3 specifies DTD’s and schema.  DOM level 3 is not supported in all browsers yet.

 

›› go to examples ››