getNamedItemNS Method
Last Updated: 08-26-2005
Retrieves from an Attributes collection the attribute with the specified local name and namespace URI.

Syntax
var oNode = Attributes.getNamedItemNS(sNamespaceURI, sLocalName);

Parameters
sNamespaceURI Required. The namespace URI of the desired attribute in the collection.
sLocalName Required. The local name of the desired attribute in the collection.

Return Value
The attribute in the collection with the specified local name and namespace URI, or null if there is no such attribute.

Examples

Suppose you have an XML document structured like the following:

<?xml version="1.0"?>
<?access-control allow="*"?>
<root xmlns="http://www.acme.org/" 
    xmlns:c="http://www.coyote.net/" 
    xmlns:d="http://www.roadrunner.net/" 
    attr1="v1" attr2="v2" d:attr4="v4" c:attr3="v3" />

Here is a program that uses the getNamedItemNS method to retrieve and report information about the attribute of the root element whose namespace URI is "http://www.coyote.net/" and local name is "attr3".

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

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

<form>
  <block>

    <script>
    <![CDATA[
    var root = dom.documentElement;
    var rootAttrs = root.attributes;
    var attr = 
      rootAttrs.getNamedItemNS('http://www.coyote.net/', 'attr3');
    vxmllog("The value of the attribute with local name " +
      attr.localname + "and namespace URI " +
      attr.namespaceURI + " is " + 
      attr.value);
    ]]>
    </script>
    
  </block>
</form>  

</vxml>


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