XML DOM getAttributeNS() Metode
❮ Elementvoorwerp
Voorbeeld
Die volgende kodefragment laai " books_ns.xml " in xmlDoc en kry die "lang"-kenmerkwaarde van die eerste <title>-element:
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("title")[0];
var
ns = "https://www.w3schools.com/children/";
document.getElementById("demo").innerHTML =
x.getAttributeNS(ns, "lang");
}
Uitset:
en
Definisie en gebruik
Die getAttributeNS() metode kry 'n kenmerkwaarde deur naamruimte-URI en naam.
Sintaksis
elementNode.getAttributeNS(ns,name)
Parameter | Description |
---|---|
ns | Required. Specifies the namespace URI to get the attribute value from |
name | Required. Specifies the attribute to get the attribute value from |
❮ Elementvoorwerp