How to use of Nodes of XPath in XML

In this article I will explain the relationship between nodes.
  • 1979


In this article I will explain the relationship between nodes that who is the parent node, child node,sibling etc.For this I take a example like,


<?xml version="1.0" encoding="utf-8" ?>




  <address street="12">Delhi</address>




Parent Node

Each element and attribute have atleast one parent, In this above example the student is the parent of name,rollnumber,address and phonenumber.Address is the parent of street.



The element nodes in the document may have zero,one,or many children. In the above example all the element name,rollnumber,address and phonenumber are the children of student.



The Nodes that have the same parents are knows as siblings. In the above example the nodes name,rollnumber,address and phonenumber all are siblings.


A node's parent, or the parent node of the parent is known as ancestors. In the above example the ancestors of the name element is the student element.


A node's children, or the child node of the child is known as descendants. In the above example the descendants of student element are name,rollnumber,address,phonenumber.

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.