BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

XML Tree Structure

By Chaitanya Singh | Filed Under: XML Tutorial

In the previous tutorials we learned about XML syntax and discussed few examples of XML. In this guide, we will talk about the structure of a XML document.

XML Tree

XML document has a tree structure, where the root element is at the top and the child elements are connected to the root elements, the same way, how leaves are connected to tree through branches. We will first see an example of XML document and then we will draw a tree structure based on the example.

Example of XML document

<?xml version="1.0" encoding="UTF-8"?>
<company>
  <employee>
    <name>Negan</name>
    <age>40</age>
    <email>[email protected]</email>
    <address>
      <city>Noida</city>
      <state>Uttar Pradesh</state>
      <pin>201301</pin>
      <landmark>Near hill top</landmark>
    </address>
  </employee>
</company>

Tree Structure

The tree structure of the above XML document would look like this:
XML Tree Structure

Root element: <company>
Child elements: <name>, <age>, <email> & <address>
Sub-child elements: <city>, <state>, <pin> & <landmark>

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap