एक्सएमएल डोम लंबाई संपत्ति
NamedNodeMap वस्तु
उदाहरण
निम्नलिखित कोड खंड " books.xml " को xmlDoc में लोड करता है और पहले <book> तत्व में विशेषताओं की संख्या प्राप्त करता है:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
function myFunction(xml) {
var xmlDoc = xml.responseXML;
var x =
xmlDoc.getElementsByTagName("book");
document.getElementById("demo").innerHTML =
"Number of
attributes in the first book element: " +
x.item(0).attributes.length;
}
उपरोक्त कोड का आउटपुट होगा:
Number of attributes in the first book element:
1
परिभाषा और उपयोग
लंबाई की संपत्ति NamedNodeMap में नोड्स की संख्या लौटाती है।
वाक्य - विन्यास
nodemapObject.length
ट्राई-इट-योरसेल्फ डेमो
NamedNodeMap वस्तु