documentElement Property
Retrieves the root element node of the document.

Syntax
var oRootElement = document.documentElement;

Possible Values
oRootElement A reference to the root document element.

Remarks
A valid XML document contains a single root document element. The documentElement property returns a reference to that node in the DOM.
Examples

The example below utilizes the following sample data describing a stock quote. In this sample data, "quote" is the name of the root document element.

<?xml version="1.0"?>
<?access-control allow="*"?>
<quote>
   <name>Ford Motor Company</name>
   <ticker>F</ticker>
   <open>28.35</open>
   <last>28.72</last>
   <change>.54</change>
   <day_high>29.03</day_high>
   <day_low>28.03</day_low>
</quote>

The following example uses the documentElement property to assign a reference to the root document element to an ECMAScript variable. The code then iterates through the root document element for nodes named "name" and "last". It reads the values contained within these nodes back to the user.

<vxml version="2.0">
   <data name="oQuote" src="quote.exml"/>
   <script><![CDATA[
      var oRoot = oQuote.documentElement;
      // retrieve the company name and price per share
      var sCoName = "unknown", fLast = 0.0;
      for (var iChild = 0; iChild < oRoot.childNodes.length; iChild++)
      {
         var oChild = oRoot.childNodes.item(iChild);
         if ("name" == oChild.nodeName)
         {
            sCoName = oChild.firstChild.data;
         }
         else if ("last" == oChild.nodeName)
         {
            fLast = parseFloat(oChild.firstChild.data, 10);
         }
      }
   ]]>
   </script>
   <form id="read_quote">
   <block>
      <audio><value expr="sCoName"/> is currently at <value expr="fLast"/></audio>
   </block>
   </form>
</vxml>



Applies To
document
[24]7 Inc.| Terms of Service| Privacy Policy| General Disclaimers