Root element
Encyclopedia
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
on the document called
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 instruction
s 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
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....
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
World Wide Web Consortium
The World Wide Web Consortium is the main international standards organization for the World Wide Web .Founded and headed by Tim Berners-Lee, the consortium is made up of member organizations which maintain full-time staff for the purpose of working together in the development of standards for the...
defines not only the specifications for XML itself, but also the DOM
Document Object Model
The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...
, which is a platform- and language-independent standard object model for representing XML documents. DOM Level 1 defines, for every XML document, an object
Object (computer science)
In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure...
representation of the
document
itself and an attribute or propertyProperty (programming)
A property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field and a method. Properties are read and written like fields, but property reads and writes are translated to get and set method calls...
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 instruction
Processing Instruction
A Processing Instruction is an SGML and XML node type, which may occur anywhere in the document, intended to carry instructions to the application....
s 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