XML DOM lookupNamespaceURI() Method

Definition and Usage

The lookupNamespaceURI() method returns the namespace matching the specified prefix on the current node.

Syntax:

elementNode.lookupNamespaceURI(prefix)
Parameter Description
prefix Required. String value, specifying the prefix to match.

Example

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

The following code snippet finds the namespace matching the prefix "c" in the first <book> element:

xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("book")[0];
document.write(x.lookupNamespaceURI("c"));

The output of the above code is:

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