XML DOM nodeType ပိုင်ဆိုင်မှု
❮ Attr Object
ဥပမာ
အောက်ဖော်ပြပါ ကုဒ်အပိုင်းအစသည် " books.xml " ကို xmlDoc သို့ တင်စေပြီး၊ အမျိုးအစား ရည်ညွှန်းချက်၏ node အမည်၊ node တန်ဖိုးနှင့် node အမျိုးအစားကို ပြသသည်-
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].nodeName +
" = " +
x.item(i).attributes[0].nodeValue
+
" (nodetype: " + x.item(i).attributes[0].nodeType
+ ")" + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
အထွက်-
category = cooking (nodetype: 2)
category = children (nodetype: 2)
category = web (nodetype: 2)
category = web (nodetype: 2)
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
nodeType ပိုင်ဆိုင်မှုသည် node အမျိုးအစားကို ပြန်ပေးသည်။
အထားအသို
attrObject.nodeType
❮ Attr Object