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