XML – Ancestor
XML family tree can understand better with some relations between elements hierarchy. We know that elements within the elements is the regular structure of XML which consists one root element for all.
Every inner element will have one or more outer elements which can be identified as Ancestors.
Please find the below example and identify the ancestors for element “city”.
<?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 Ancestor elements of “city”