Root Element

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.

content

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.

text

Famous quotes containing the words root and/or element:

    Black creeps from root to root,
    each leaf
    cuts another leaf on the grass,
    shadow seeks shadow,
    then both leaf
    and leaf-shadow are lost.
    Hilda Doolittle (1886–1961)

    The geometry of landscape and situation seems to create its own systems of time, the sense of a dynamic element which is cinematising the events of the canvas, translating a posture or ceremony into dynamic terms. The greatest movie of the 20th century is the Mona Lisa, just as the greatest novel is Gray’s Anatomy.
    —J.G. (James Graham)