XML DOM lookupNamespaceURI() method
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 functions 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/