Metodo lookupNamespaceURI() del DOM XML
Definizione e utilizzo
lookupNamespaceURI()
Il metodo restituisce l'URI di namespace corrispondente al prefisso specificato sul nodo corrente.
Sintassi
elementNode.lookupNamespaceURI(prefix)
Parametro | Descrizione |
---|---|
prefix | Obbligatorio. Stringa, specifica il prefisso da cercare. |
Esempio
Il codice seguente caricherà "books_ns.xml" in xmlDoc e troverà l'URI di namespace con prefisso "c":
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"); }