XML DOM replaceData() method

definition and usage

replaceData() method သို့ ပြောင်းလဲသွင်း မှတ်ချက် လက်တွေ့ အချက်အလက်များ

ဘာသာစကား

commentNode.replaceData(start,length,string)
ပါဝင်သည် ကျမ်းကိုး
start ကိစ္စခွင်
length ကိစ္စခွင်
string ကိစ္စခွင်

အကြောင်းကြောင်း

အောက်ပါ ကြောင်းအား "books_comment.xml" သို့ တင်သွင်းပြီး xmlDoc အရ ပထမ <book> အရေးကြီး လက်တွေ့ မှတ်ချက် အရ "Simple" ကို "Easy" ဖြင့် ပြောင်းလဲသွင်းပါ

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
       myFunction(this);
   }
};
xhttp.open("GET", "books_comment.xml", true);
xhttp.send();
function myFunction(xml) {
    var x, i, txt, xmlDoc;
    xmlDoc = xml.responseXML;
   txt = "";
    x = xmlDoc.getElementsByTagName("book")[0].childNodes;
    for (i = 0; i < x.length; i++) {
    // ဖွဲ့စည်းကြောင်း လက်တွေ့ မှတ်ချက် လက်ဆုံးဖြတ်သည်
        if (x[i].nodeType == 8) {
            x[i].replaceData(4, 6, "Easy");
            txt += x[i].data + "<br>";
        }
    }
    document.getElementById("demo").innerHTML = txt;
}

ကိုယ်တိုင် အက်သုံးစွဲပါ

အပြီးအပိုင်း အက်ဥပဒေတွင် နောက်ဆုံး အချက်များ ကို အသုံးပြုခြင်း နှင့် if စစ်ဆေး အချက်များ ကို အသုံးပြုခြင်း ဖြင့် သာ သတင်းထိုး အချက်များ ကို ပြုပြင်ခြင်း ပြုလုပ်ပါ။ သတင်းထိုး အချက်များ သည် အချက် 8 ဖြစ်သည်။