XML DOM lookupNamespaceURI() Method

Node Object Reference Manual

Definition and Usage

The lookupNamespaceURI() method can return the namespace URI that matches the specified prefix on a node.

Syntax:

nodeObject.lookupNamespaceURI(prefix)
Parameter Description
Prefix Required. Prefix.

Example

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

The following code snippet can find the namespace of the prefix "c" in the first <book> element:

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

Output:

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

Node Object Reference Manual