Metodo lookupPrefix() XML DOM
Definizione e uso
lookupPrefix()
Il metodo restituisce il prefisso associato all'URI di namespace dato.
Sintassi
nodeObject.lookupPrefix(namespaceURI)
Parametri
Parametri | Descrizione |
---|---|
namespaceURI | Obbligatorio. Stringa. Specifica l'URI di namespace da cercare. |
Dettagli tecnici
Versione DOM: | Core Level 3 Node Object |
---|---|
Ritorno: | Stringa. Prefisso associato all'URI di namespace specificato. |
Esempio
Il codice seguente carica "books_ns.xml" nel xmlDoc e cerca il prefisso dell'URI di namespace dato:
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.codew3c.com/meishi/"); }
Supporto dei browser
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Supporto | Supporto | Supporto | Supporto | Supporto |
Tutti i browser mainstream supportano lookupPrefix()
Metodo.
Nota: Internet Explorer 9 e versioni precedenti non supportano questo metodo.