getNamedItem Method
Last Updated: 08-26-2005
Retrieves from an Attributes collection the attribute with the specified nodeName.

Syntax
var oNode = Attributes.getNamedItem(sName);

Parameters
sName Required. The nodeName of the desired attribute in the collection.

Return Value
The attribute in the collection with the specified nodeName.

Examples

Suppose you have an XML document structured like the following:

<?xml version="1.0"?>
<?access-control allow="*"?>
<root attr1="v1" attr2="v2" attr3="v3"/>

Here is a program that uses the getNamedItem method to retrieve and report the values of the attributes of the root element whose names are "attr1" and "attr3".

<vxml version="2.1"
  xmlns="http://www.w3.org/2001/vxml">

<data name="dom" src="dom_getNamedItem.xml"/>

<form>
  <block>

    <script>
    <![CDATA[
    var root = dom.documentElement;
    var rootAttrs = root.attributes;
    var attr1 = rootAttrs.getNamedItem('attr1');
    var attr3 = rootAttrs.getNamedItem('attr3');
    vxmllog("The value of the attr1 attribute is " + 
      attr1.nodeValue);
    vxmllog("The value of the attr3 attribute is " + 
      attr3.nodeValue);
    ]]>
    </script>
    
  </block>
</form>  

</vxml>


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