XML – Tree

XML family tree structure depicts the ancestor or descendant elements, parent elements, child elements and we can segregate them as branches also for our understanding. Anyhow, there should be one root parent element for any other child elements and parent elements nested inside.

Here we can take an example of a company.xml which contains the information about their employee_list and customer_list as parent elements. where in turn those employee and customer parent elements carry the data inside the child elements called name, city, location.

Example:

XML Family Tree

<?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> 

XML tree - i2tutorials.com