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