Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Root element
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Each [[XML]] document has exactly one single '''root element'''. It encloses all the other elements and is, therefore, the sole parent element to all the other elements. ROOT elements are also called document elements. In [[HTML]], the root element is the <code><html></code> element.<ref>{{Cite web|url=https://www.w3.org/TR/html5/semantics.html#the-html-element|title=4 The elements of HTML β HTML5|website=www.w3.org|access-date=2017-10-10}}</ref> The [[World Wide Web Consortium]] defines not only the specifications for XML itself,<ref>[http://www.w3.org/TR/xml/ The current W3C XML 1.0 specification]</ref> but also the [[Document Object Model|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 (computer science)|object]] representation of the <code>document</code> itself and an [[Property (programming)|attribute or property]] on the document called <code>documentElement</code>. This property provides access to an object of type <code>element</code> which directly represents the root element of the document.<ref>[http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#i-Document The 'documentElement' definition in the W3C DOM Level 1 specification]</ref> <syntaxhighlight lang="xml"> <parent> <child>content</child> <child attribute="att"/> </parent> </syntaxhighlight> There can be other [[XML node]]s outside of the root element.<ref>[http://www.w3.org/TR/2006/REC-xml-20060816/#sec-well-formed The 'well-formed document' section of the W3C XML specification]</ref> 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 root element, there may be further optional comments, processing instructions and whitespace within the document.<ref>[http://www.w3.org/TR/2006/REC-xml-20060816/#NT-prolog The 'prolog' section of the W3C XML specification]</ref> Within the root 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 <code>rootElement</code> element. <syntaxhighlight lang="xml" line> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE example [<!ENTITY copy "©">]> <rootElement attribute="xyz"> <contentElement/> </rootElement> <!-- comment nodes may appear almost anywhere --> </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)