A tree structure is formed by an XML document. It starts at “the root” and branches to “the leaves”.
Example:
Books.xml:
ABC Unknown 2020 100.00 XQuery Book Author 1 Author 2 Author 3 Author 4 2004 350.00
Output: XML Tree:
XML Tree Structure:
Formed as element trees, these XML documents as an XML tree start at a root element. It branches from the root to child elements, where any element can have sub-elements or child elements.
Syntax:
.....
Here, the information about books in a bookstore are contained in the XML document. To describe the relationships between elements, the parent, child, and sibling terms are used. Parents have children and vice versa. Children on the same level are called Siblings (brothers and sisters). Any element can have text content and attributes.
Self-Describing Syntax:
A much self-describing syntax is used by XML. The XML version and the character encoding is defined by a prolog:
The root element is the next line of the document:
The <book> element is started by the next line:
There are 4 child elements in the <book> elements including, <title>, <author>, <year>, <price>:
ABC Unknown 2020 100.00
The book element is ended by the next line:
The XML though is quite self-descriptive, with sender information, receiver information, a heading, and a message body, but still, it does not do anything and is just information wrapped in tags.