एक्सएमएल डोम स्थानीय नाम संपत्ति
Attr वस्तु
उदाहरण
निम्न कोड खंड " books_ns.xml " को xmlDoc में लोड करता है और "lang" विशेषताओं का स्थानीय नाम देता है:
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 x, i, xmlDoc, txt;
xmlDoc = xml.responseXML;
txt = "";
x =
xmlDoc.getElementsByTagName("title");
for (i = 0; i <
x.length; i++) {
txt += "Local
name: " + x.item(i).attributes[0].localName + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
उपरोक्त कोड का आउटपुट होगा:
Local name: c
Local name: x
परिभाषा और उपयोग
स्थानीय नाम संपत्ति किसी विशेषता के नाम का स्थानीय भाग लौटाती है।
वाक्य - विन्यास
attrObject.localName
Attr वस्तु