XML Tree Structure

  • XML tree structure is also called as tree model or hierarchical model.
  • XML document must contain a root element and all elements in the document can contain sub-elements, text and attributes.
  • The complex elements are represented with the help of internal nodes and simple elements are represented with leaf node.
Example: In the following example, employee information is represented with tree structure, which can be used in XML document.

xml tree strecture

Textual representation of the above document in the form of XML document can be as follows:

Example: XML tree structure

<Employee>
     <Name>
          <First name>Brian</First name>
          <Last name>Lara<</Last name>
     </Name>
     <Contact>
          <Mobile>9800000000</Mobile>
          <Landline>020222222</Landline>
     </Contact>
     <Address>
          <City>Pune</city>
          <Street>Tilak road</Street>
          <Zip code>4110</Zip code>
     </Address>
</Employee>