Proprietà namespaceURI del DOM XML
Definizione e uso
namespaceURI
L'attributo restituisce l'URI dello spazio dei nomi dell'elemento selezionato.
Se il nodo selezionato non è un elemento o un attributo, questa proprietà restituisce sempre NULL.
Sintassi
elementNode.namespaceURI
Esempio
Il codice seguente carica "books_ns.xml" nella xmlDoc e recupera l'URI di spazio dei nomi dalla prima etichetta <title>:
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("c:title")[0]; document.getElementById("demo").innerHTML = x.namespaceURI; }