XML DOM createTextNode() နည်းပါး

အသုံးပြုခြင်း နှင့် အပြုအရင်

createTextNode() နည်းပါး ကို စကား အီးအီး ကို ဖန်တီး

ဒီ နည်းပါး က Text အား ပြန်လည်ပေး

ပုံစံ

createTextNode(text)
အပ်လိုက် ဖော်ပြ
text အချက်အလက်

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

အောက်ပါ ကြောင်းအား "books.xml" ကို xmlDoc ထဲသို့ သို့မဟုတ် နှင့် ရှိသော အကိုင်း <book> အစီအစဉ် တွင် အသုံးပြုသော အီးအီး ကို ပြောက်ပေး

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, y, z, i, xLen, yLen, newEle, newText, xmlDoc, txt;
    xmlDoc = xml.responseXML;
    txt = "";
    x = xmlDoc.getElementsByTagName("book");
    xLen = x.length;
    // အစီအစဉ် အီးအီး နှင့် စကား အီးအီး ကို ဖန်တီး
    for (i = 0; i < xLen; i++) {
        newEle = xmlDoc.createElement("edition");
        newText = xmlDoc.createTextNode("first");
        newEle.appendChild(newText);
        x[i].appendChild(newEle);
    }
    // အားလုံး title နှင့် edition တို့ ပြောက်ပေး
    y = xmlDoc.getElementsByTagName("title");
    yLen = y.length
    z = xmlDoc.getElementsByTagName("edition");
    for (i = 0; i < yLen; i++) {
        txt += y[i].childNodes[0].nodeValue +
        " - Edition: " +
       z[i].childNodes[0].nodeValue + "<br>";
    }
    document.getElementById("demo").innerHTML = txt;
}

ကျွန်ုပ်သို့ ပြုလုပ်