XML Tree Structure

XML tree structure start to a Parent root from top of the side. Every XML documents have only one root element.

XML was describe a tree structures of data. And tree structure have one root, child elements, branches, attributes, values. Following are simple XML structures.

<root>
  <element>
    <subelement>...</subelement>
  </element>
</root>

So upto now you know XML have ability to specify new tags and also create a nested tags to make a strict valid tree structure for exchanging data.

XML Tree Structure

XML Tree Structure

Above visual tree structure assume our example base on this structure make one XML document including all that describe information.

<employee>
  <emp_info id="1">
    <name>
      <first_name>Opal</first_name>
      <middle_name>Venue</middle_name>
      <last_name>Kole</last_name>
    </name>
    <contact_info>
      <company_info>
        <comp_name>Odoo (formally OpenERP)</comp_name>
        <comp_location>
          <street>Tower-1, Infocity</street>
          <city>GH</city>
          <phone>000-478-1414</phone>
        </comp_location>
        <designation>Junior Engineer</designation>
      </company_info>
    <phone>000-987-4745</phone>
    <email>[email protected]</email>
    </contact_info>
  </emp_info>
</employee>

Run it...   »

Tree Structure Rules

Tag Name label for a section of data. Label must be relative to section data.

Section Element Section of data beginning with <tagname> and ending with </tagname>.
Example. <name> ... </name>

Nested Every element must be properly nested. Example: <name> <fist_name> ... </first_name> </name>

Attribute you can specify attribute name=value inside the starting tag of the element. You can specify several attributes.

Note Attributes specify for identify the elements.