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