Proprietà XML DOM baseURI
❮ Oggetto nodo
Esempio
Il seguente frammento di codice carica " books_ns.xml " in xmlDoc e restituisce l'URI di base degli elementi <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
x, i, xmlDoc, txt;
xmlDoc = xml.responseXML;
txt = "";
x = xmlDoc.getElementsByTagName("title");
for (i = 0; i <
x.length; i++) {
txt +=
"Base URI: " + x.item(i).baseURI + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
L'output del codice sopra sarà:
Base URI: https://www.w3schools.com/xml/books_ns.xml
Base URI:
https://www.w3schools.com/xml/books_ns.xml
Definizione e utilizzo
La proprietà baseURI restituisce l'URI di base assoluto di un nodo.
Supporto browser
La proprietà baseURI è supportata in tutti i principali browser, ad eccezione di Internet Explorer.
Sintassi
nodeObject.baseURI
Dettagli tecnici
Valore di ritorno: | Una stringa che rappresenta l'URI di base assoluta di un nodo |
---|---|
Versione DOM | Oggetto nodo di livello 3 di base |
❮ Oggetto nodo