XML – Sibling

In the XML family tree , sibling can be identified as the element which is in the same hierarchy of any other element in the XML document.

For suppose, if we have 3 elements called element A , element B, element C and if the element A is the outer element of both element B and element C then element C will be called as sibling of element B.

Please find the below example and identify the sibling of element “location”.

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

<company> 
<employee_list> 
	<employee> 
		<name> Hari</name> 
		<city> hyderabad</city> 
	</employee> 
	<employee> 
		<name> sneha</name> 
		<city> banglore</city> 
	</employee> 

</employee_list> 
<customer_list> 
	<customer> 
		<name> Sanjay</name> 
		<location> Mumbai</location> 
	</customer> 
	<customer> 
		<name> Micheal</name> 
		<location> Washington</location> 
	</customer> 
</customer_list> 
</company> 

Below figure shows the sibling of element “location”

XML sibling - i2tutorials.com