XML - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

XML Tree

XML Tree

shape Description

An XML Tree Structure allows context relationships between XML document elements that have to be expressed to any level of difficulty. A Tree Structure can be defined as a type of data structure inside which every element is connected to multiple elements directly beneath it and this connection can be termed as Branches. As the tree is drawn with the root placed at the top, it is called as Inverted tree. Syntax: [xml] <root> <child> <subchild>.....</subchild> </child> </root> [/xml] The elements present at the very bottom of an inverted tree i.e. is the part that doesn't have no elements are called as Leaves. Hierarchical File Structures are represented by Inverted trees. In this case, the leaves are files and the other elements above the leaves are directories. A binary tree is a special type of inverted tree in which each element has only two branches below it.

shape Conceptual Figure

An XML tree begins with the root element and branches from the root to child elements. Below is an example for XML Tree Structure with a root element "Book". In the above tree structure, Book is the root element, Title, Author, Chapter are the Branches of the root. In one of the branch Chapter, there are sub-branches like Title, Summary, Paragraph and this Tree structure goes on with multiple sub-elements.

shape Example

Below is the XML code for above mentioned tree structure. [xml] <?xml version="1.0"?> <Book> <Title>XML Tutorials</Title> <Author>Mary</Author> <Chapter> <Title>XML Introduction</Title> <Summary> XML is derived form SGML.</Summary> <Paragraph> <Text>XML is “Extensible Markup Language” in which the user can store, transport and exchange data. XML concentrates only on what data means unlike HTML concentrating on Layout also.</Text> <Figure> <Title>XML Structure</Title> </Figure> </Paragraph> </Chapter> </Book> [/xml]

Summary

shape Key Points

  • A Tree Structure can be defined as a type of data structure inside which every element is connected to multiple elements.
  • The elements present at the very bottom of an inverted tree i.e. is the part that doesn’t have no elements are called as Leaves.