Element Object
Represents an XML element node in the Document Object Model (DOM).

Methods
getAttribute Retrieves the value of the specified attribute.
getAttributeNS Retrieves the value of the attribute with the specified local name and namespace URI.
getAttributeNode Retrieves an Attribute object encapsulating the named attribute.
getAttributeNodeNS Retrieves an Attribute object with the specified local name and namespace URI.
getElementsByTagName Returns a NodeList collection of descendant element nodes with the specified name.
getElementsByTagNameNS Returns a NodeList collection of descendant element nodes with the specified local name and namespace URI.
hasAttribute Returns whether or not the Element has the specified attribute.
hasAttributeNS Returns whether or not the Element has an attribute with the specified local name and namespace URI.

Remarks
The Element object is a specialized node object in an XML document that can contain other elements and can have attributes.
Examples

The example below uses the following data. In this data, the following elements are represented as Element objects in the XML DOM: quote, name, ticker, and last. The name, ticker, and last elements contain text nodes.

<?xml version="1.0"?>
<?access-control allow="*"?>
<quote>
   <name>Ford Motor Company</name>
   <ticker>F</ticker>
   <last>28.72</last>
</quote>

The following example walks the children of the the root document element and prints the nodeName and the data contained within the TextNode of each Element node to the log.

<vxml version="2.0">
   <data name="oData" src="shortquote.exml"/>
   <form>
      <script>
      <![CDATA[
      // cache the root document element
      var oRoot = oData.documentElement;
      // retrieve the collection of children from the root doc element
      var oChildren = oRoot.childNodes;
      // iterate
      for (var i = 0; i < oChildren.length; i++)
      {
         // cache each child node in a temporary variable
         var oNode = oChildren.item(i);
         // *in this data set* each element node contained within the root element
         // contains a text node containing the desired data
         vxmllog(oNode.nodeName + "=" + oNode.firstChild.data);
      }
      ]]>
       </script>
   </form>
</vxml>


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