How to use of Nodes of XPath in XML

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

Introduction

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,

Example

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

<student>

  <name>XYZ</name>

  <rollnumber>32</rollnumber>

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

  <phonenumber>123456789</phonenumber>

</student>

 

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.

 

Children
 

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.

 

Siblings
 

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.

Ancestors

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.

Descendants

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

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.