XML DOM တန်ဖိုး Property
❮ Attr Object
ဥပမာ
အောက်ဖော်ပြပါ ကုဒ်အပိုင်းအစသည် " 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
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
တန်ဖိုးပိုင်ဆိုင်မှုသည် attribute တစ်ခု၏တန်ဖိုးကို ပြန်ပေးသည်။
အထားအသို
attrObject.value
❮ Attr Object