XML-DOM -LookupNamespaceURI()- Methode
❮ Knotenobjekt
Beispiel
Das folgende Codefragment lädt „ books_ns.xml “ in xmlDoc und findet den Namespace-URI für das angegebene „c“-Präfix:
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");
}
Ausgabe:
https://www.w3schools.com/children/
Definition und Verwendung
Die Methode lookupNameSpaceURI() gibt den Namespace-URI zurück, der einem bestimmten Präfix zugeordnet ist.
Browser-Unterstützung
Die Methode lookupNamespaceURI() wird in allen gängigen Browsern unterstützt.
Hinweis: Internet Explorer 9 und früher unterstützen diese Methode nicht.
Syntax
nodeObject.lookupNamespaceURI(prefix)
Parameter
Parameter | Type | Description |
---|---|---|
prefix | String | Required. Specifies the prefix to look for |
Rückgabewert
Type | Description |
---|---|
String | The namespace URI associated with the specified prefix |
Technische Details
DOM-Version | Knotenobjekt der Kernebene 3 |
---|
❮ Knotenobjekt