XML DOM lookupNameSpaceURI() Method
Definition and Usage
lookupNameSpaceURI()
The method returns the namespace URI associated with the given prefix.
Syntax
nodeObject.lookupNamespaceURI(prefix)
Parameters
Parameters | Description |
---|---|
prefix | Required. String. Specifies the prefix to be searched for. |
Technical Details
DOM Version: | Core Level 3 Node Object |
---|---|
Return value: | The namespace URI associated with the specified prefix. |
Example
The following code loads "books_ns.xml" into xmlDoc and searches for the namespace URI with the given "c" prefix:
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myFunction(this); } }; xhttp.open("GET", "books_ns.xml", true); xhttp.send(); function myFunction(xml) { var xmlDoc = xml.responseXML; var x = xmlDoc.getElementsByTagName("book")[0]; document.getElementById("demo").innerHTML = x.lookupNamespaceURI("c"); }
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
All mainstream browsers support lookupNamespaceURI("c");
Method.
Note: Internet Explorer 9 and earlier versions do not support this method.