XML documents form a tree structure that starts at "the root" and branches to "the leaves".
The image above represents books in this XML:
XML documents are formed as element trees.
An XML tree starts at a root element and branches from the root to child elements.
All elements can have sub elements (child elements):
The terms parent, child, and sibling are used to describe the relationships between elements.
Parent have children. Children have parents. Siblings are children on the same level (brothers and sisters).
All elements can have text content (Harry Potter) and attributes (category="cooking").
XML uses a much self-describing syntax.
A prolog defines the XML version and the character encoding:
The next line is the root element of the document:
The next line starts a <book> element:
The <book> elements have 4 child elements: <title>, <author>, <year>, <price>.
The next line ends the book element:
You can assume, from this example, that the XML document contains information about books in a bookstore.