Metodo XML DOM lookupPrefix()
❮ Oggetto nodo
Esempio
Il seguente frammento di codice carica " book_ns.xml " in xmlDoc e trova il prefisso per l'URI dello spazio dei nomi specificato:
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.lookupPrefix("https://www.w3schools.com/children/");
}
Produzione:
c
Definizione e utilizzo
Il metodo lookupPrefix() restituisce il prefisso associato a un determinato URI dello spazio dei nomi.
Supporto browser
Il metodo lookupPrefix() è supportato in tutti i principali browser.
Nota: Internet Explorer 9 e versioni precedenti non supportano questo metodo.
Sintassi
nodeObject.lookupPrefix(namespaceURI)
Parametri
Parameter | Type | Description |
---|---|---|
namespaceURI | String | Required. Specifies the namespace URI to look for |
Valore di ritorno
Type | Description |
---|---|
String | The prefix associated with the specified namespace URI |
Dettagli tecnici
Versione DOM | Oggetto nodo di livello 3 di base |
---|
❮ Oggetto nodo