Root element

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,[1] 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.[2]

<parent>
  <child>content</child>
  <child attribute="att"/>
</parent>

There can be other XML nodes outside of the root element,[3] 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.[4]

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.

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE example [<!ENTITY copy "&#xA9;">]>
 <?php $a = 'Processing instruction'; ?>
  
 <rootElement attribute="xyz">
    
    <?php echo 'another processing instruction'; ?>
    <contentElement/>
    text
 </rootElement>
  
 <!-- comment nodes may appear almost anywhere -->

References

  1. ^ The current W3C XML 1.0 specification
  2. ^ The 'documentElement' definition in the W3C DOM Level 1 specification
  3. ^ The 'well-formed document' section of the W3C XML specification
  4. ^ The 'prolog' section of the W3C XML specification



Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • root — root1 [ro͞ot, root] n. [ME rote < Late OE < ON rot, akin to OE wyrt, Ger wurzel < IE base * wrād , twig, root > Gr rhiza, L radix, root, ramus, branch] 1. the part of a plant, usually below the ground, that lacks nodes, shoots, and… …   English World dictionary

  • element — [n1] essential feature aspect, basic, basis, bit, component, constituent, detail, drop, facet, factor, fundamental, hint, ingredient, item, material, matter, member, part, particle, particular, piece, portion, principle, root, section, stem,… …   New thesaurus

  • Root group — A root group G, is a group together with a set of prime numbers P={p 1,p 2,...}, satisfying the axiom::g in G land pin P Rightarrow exists h in G, ; h^p=g;.To specify the set of primes, a group may be referred to as a P root group. For a single… …   Wikipedia

  • Root of unity — The 5th roots of unity in the complex plane In mathematics, a root of unity, or de Moivre number, is any complex number that equals 1 when raised to some integer power n. Roots of unity are used in many branches of mathematics, and are especially …   Wikipedia

  • Root system — This article discusses root systems in mathematics. For root systems of plants, see root. Lie groups …   Wikipedia

  • Root nameserver — A root name server is a DNS server that answers requests for the DNS root zone, and redirects requests for a particular top level domain (TLD) to that TLD s nameservers. Although any local implementation of DNS can implement its own private root… …   Wikipedia

  • Root (chord) — This article is about chord roots. For interval roots, see interval root. Root, in red, of a C major chord (   …   Wikipedia

  • root — I. /rut / (say rooht) noun 1. a part of the body of a plant which, typically, develops from the radicle, and grows downwards into the soil, fixing the plant and absorbing nutriment and moisture. 2. a similar organ developed from some other part… …  

  • root — 1. n. & v. n. 1 a the part of a plant normally below the ground, attaching it to the earth and conveying nourishment to it from the soil. b (in pl.) such a part divided into branches or fibres. c the corresponding organ of an epiphyte; the part… …   Useful english dictionary

  • root — I. noun Usage: often attributive Etymology: Middle English, from Old English rōt, from Old Norse; akin to Old English wyrt root, Latin radix, Greek rhiza Date: 12th century 1. a. the usually underground part of a seed plant body that originates… …   New Collegiate Dictionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”