XML DOM | Node Tree

XML DOM - Node Tree


Hello folks! welcome back to a new section of our tutorial on XML DOM. In this tutorial, we are going to be studying about the XML DOM Node Tree.

In an XML document, the information is maintained in a hierarchical structure; this hierarchical structure is referred to as Node Tree. This hierarchy makes it possible for a developer to navigate around the tree in a search for specific information, thus nodes are allowed to access. The content of these nodes can be updated.


The node tree structure starts with the root element and then spreads out to the child elements until the lowest level.

Example

The following example illustrates a simple XML document whose node tree structure is shown below -

<?xml version = "1.0"?>
<Company>
   <Employee category = "Technical">
      <FirstName>Kennedy</FirstName>
      <LastName>Nkpara</LastName>
      <ContactNo>1234567890</ContactNo>
   </Employee>
   <Employee category = "Non-Technical">
      <FirstName>Stephanie</FirstName>
      <LastName>Francis</LastName>
      <ContactNo>1234667898</ContactNo>
   </Employee>
</Company>


As can be seen in example above whose pictorial representation is as shown below -

XML DOM (Pictorial representation)

  • The topmost node of a tree is known as 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 nodes <Employee> of root node <Company>, in turn consists of its own child nodes (<FirstName>, <LastName>, <ContactNo>).
  • The two child nodes, <Employee> have attribute values Technical and Non-technical, are referred to as attribute nodes.
  • The text within every node is known as the text node.


Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about XML DOM Methods.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.