XML DOM textContent 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].textContent + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
အထွက်-
cooking
children
web
web
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
စာသားအကြောင်းအရာပိုင်ဆိုင်မှုသည် ရည်ညွှန်းချက်တစ်ခု၏ စာသားအကြောင်းအရာကို သတ်မှတ်ပေးသည် သို့မဟုတ် ပြန်ပေးသည်။
အထားအသို
attrObject.textContent
ကိုယ်တိုင်စမ်းသုံးကြည့်ပါ-ဒီမိုများ
❮ Attr Object