Each XML document has exactly one single root element. This element is also known as the document element. It encloses all the other elements and is therefore the sole parent element to all the other elements.
The World Wide Web Consortium defines not only the specifications for XML itself, but also the DOM, which is a platform- and language-independent standard object model for representing XML documents. DOM Level 1 defines, for every XML document, an object representation of the document itself and an attribute or property on the document called documentElement. This property provides access to an object of type element which directly represents the root element of the document.
There can be other XML nodes outside of the root element, in particular the root element may be preceded by a prolog, which itself may consist of an XML declaration, optional comments, processing instructions and whitespace, followed by an optional DOCTYPE declaration and more optional comments, processing instructions and whitespace. After the document element there may be further optional comments, processing instructions and whitespace within the document.
Within the document element, apart from any number of attributes and other elements, there may also be more optional text, comments, processing instructions and whitespace.
A more expanded example of an XML document follows, demonstrating some of these extra nodes along with a single rootElement element.
Famous quotes containing the words root and/or element:
“She saw a dust bearing bee sink into the sanctum of a bloom; the thousand sister calxes arch to meet the love embrace and the ecstatic shiver of the tree from root to tiniest branch creaming in every blossom and frothing with delight. So this was a marriage!”
—Zora Neale Hurston (18911960)
“Lisa Fremont: Surprise is the most important element of attack. And besides, youre not up on your private eye literature. When theyre in trouble its always their girl Friday who gets them out of it.
L.B. Jeffries: Well, is she the girl who saves him from the clutches of the seductive show girls and the over passionate daughters of the rich?
Lisa Fremont: The same.
L.B. Jeffries: Thats the one, huh? But he never ends up marrying her, does he? Thats strange.”
—John Michael Hayes (b. 1919)