XML DOM - Node Tree


In this chapter, we will study about the XML DOM Node Tree. In an XML document, the information is maintained in hierarchical structure; this hierarchical structure is referred to as the Node Tree. This hierarchy allows a developer to navigate around the tree looking for specific information, thus nodes are allowed to access. The content of these nodes can then be updated.

The structure of the node tree begins with the root element and spreads out to the child elements till the lowest level.


Following example demonstrates a simple XML document, whose node tree is structure is shown in the diagram below −

<?xml version = "1.0"?>
   <Employee category = "Technical">
   <Employee category = "Non-Technical">

As can be seen in the above example whose pictorial representation (of its DOM) is as shown below −

XML Nodes Tree

  • The topmost node of a tree is called the root. The root node is <Company> which in turn contains the two nodes of <Employee>. These nodes are referred to as child nodes.

  • The child node <Employee> of root node <Company>, in turn consists of its own child node (<FirstName>, <LastName>, <ContactNo>).

  • The two child nodes, <Employee> have attribute values Technical and Non-Technical, are referred as attribute nodes.

  • The text within every node is called the text node.