nodeName Property
Last Updated: 08-25-2005
Retrieves the name of the node.

var sName = node.nodeName;

Possible Values
sName The name of the node.

You can retrieve the set of nodes in an XML document with a specific name by using the getElementsByTagName method.
Prior to revision 3, comment and processing instruction nodes in an XML document are ignored, and CDATA section nodes are treated the same as text nodes. Various types of nodes are all recognized and treated independently in revision 3 and later, and, for compliance with the Interface Node section of the DOM 2 specification, there are some differences in nodeName values for various types of nodes. The following table shows the differences between the old (pre-revision 3) and new (revision 3) nodeName values.
Node Type Old nodeName New nodeName
Attribute attribute name attribute name
CDATASection "noname" "#cdata-section"
Comment N/A "#comment"
Document "_doc" "#document"
Element tag name tag name
ProcessingInstruction N/A target property
TextNode "noname" "#text"


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.

   <name>Ford Motor Company</name>

The following example uses the nodeName property to determine if the data contains the expected root element. If so, it reads back the company name and the latest price per share.

<vxml version="2.0">
   <data name="oQuote" src="quote.xml"/>
      // compare the root element's name to an expected value
      function IsExpectedRoot(oData, sExpected)
         var oRoot = oData.documentElement;
         return (sExpected == oRoot.nodeName ? true : false);

      // return the company name from the quote data
      function GetCoName(oData)
        var oRoot = oData.documentElement;

      // return the price/share from the quote data
      function GetLast(oData)
        var oRoot = oData.documentElement;
   <form id="main">
      <if cond="oQuote &amp;&amp; IsExpectedRoot(oQuote, 'quote')">
         <audio><value expr="GetCoName(oQuote)"/> is currently at 
           <value expr="GetLast(oQuote)"/></audio>
         <audio>I'm sorry. I was unable to obtain your quote.</audio>

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