Javascript Reference
Categories: Element

javascript Element getAttributeNS( )

@March 15, 2008, 1:22 a.m.
getAttributeNS( )Firefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM 2  

getAttributeNS("namespaceURI", "localName")

  

Returns the value of the local-named attribute with a matching namespace URI within the current element. This method works like getAttribute( ) but accommodates attributes for XML documents that are labeled according to a namespace specification. The following simple XML document uses a namespace for an attribute of the libBook:title element:

<?xml version="1.0" encoding="ISO-8859-1">
<results xmlns:libBook="http://catalog.umv.edu/schema">
<libBook:title libBook:rareBooks="true">De Principia</libBook:title>
</results>?

To retrieve the value of the libBook:rareBooks attribute, the method for the element would include the getAttributeNS( ) method call with the following parameters:

getAttributeNS("http://catalog.umv.edu/schema", "rareBooks")
 
Parameters
 
  • URI string matching a URI assigned to a label earlier in the document.
  • The local name portion of the attribute.
 
Returned Value

The W3C DOM and Netscape 6 maintain attribute values exclusively as string data types.


Powered by Linode.