XML DOM namespaceURI Property

Definition and Usage

The namespaceURI property sets or returns the namespace URI of the attribute.

Syntax:

attrObject.namespaceURI

Example

In all examples, we will use the XML file books_ns.xml, and the JavaScript function loadXMLDoc().

The following code snippet returns the namespace URI of the "lang" attribute:

xmlDoc=loadXMLDoc("/example/xdom/books_ns.xml");
var x=xmlDoc.getElementsByTagName('title');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].namespaceURI);
document.write("<br />");
}

The output of the above code is:

http://www.codew3c.com/children/
http://www.codew3c.com/xml/