Home >>XML Tutorial >XML Tree Structure

XML Tree Structure

XML Tree Structure

An XML document has a structure and is self descriptive. It forms a tree framework that is called XML tree. The tree structure allows definition of an XML document simple.

A configuration of a tree includes the root element (as the parent), the child element, etc. Traversing all successive branches and sub-branches, and leaf nodes from the base, is quite simple.

Example of an XML document

<?xml version="1.0"?>  
<contact>+91 8953428061</contact>  
<email>[email protected]</email>  
<state>Uttar Pradesh</state>  

First line in the following case is the XML statement. This defines edition 1.0 of XML. The next line shows the document's root-element (college). There is one more element inside that (student). There are five divisions called < firstname >, < lastname >, < contact >, < Email > and < address > in the student element.

The branch < address > includes three sub-branches called < city >, < state > and < pin >.

XML Tree Rules

Those rules are used to evaluate the relationship between the elements. This indicates whether the other item is a child or a parent.

Descendants: If element A is represented by element B, then a descendent of B is identified. In the case above "College" is the root factor and all the other components are "College" descendants

Ancestors: Another element is named the underlying element which contains other elements "Ancestor." Root item (College) is ancestor of all other elements in the above case.