XML DOM cloneNode() ဘဏ္ဍာရေး

အသုံးပြုနည်း

cloneNode() အသုံးပြုပါက အသုံးစံ အဖြစ် အခြား အသုံးစံ ကို ပြန်လည်ထုတ်ပါးသည်။

အပိုင်းအချက်

nodeObject.cloneNode(deep)

ပါဝင်သည်

ပါဝင်သည် ဖော်ပြ
deep

ဘာသာ

  • true - ကိုယ်ပိုင်အသုံးစံ နှင့် အခြေအနေ နှင့် ကျန်ရှိသော အသုံးစံ
  • false - ကိုယ်ပိုင်အသုံးစံ နှင့် အခြေအနေ

နည်းပါး

DOM မူဝါဒ Core Level 1 Node Object
ထုတ်ပါး Node အပေါင်းအချင်း အပေါင်းအချင်း

အမှတ်

အောက်ပါ ကြောင်းလုပ်မှုများ "books.xml" တွင် ရှိသော 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, cloneNode, i, xmlDoc, txt;
    xmlDoc = xml.responseXML;
    txt = "";
    x = xmlDoc.getElementsByTagName('book')[0];
    cloneNode = x.cloneNode(true);
    xmlDoc.documentElement.appendChild(cloneNode);
    // တိုက်ရိုက် ရှိသော title
    y = xmlDoc.getElementsByTagName("title");
    for (i = 0; i < y.length; i++) {
        txt += y[i].childNodes[0].nodeValue + "<br>";
    }
    document.getElementById("demo").innerHTML = txt;
}

ကိုယ်တိုင် စစ်ဆေးကြည့်ပါ

ဘရပ်သျူ ထောက်ပံ့

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
ထောက်ပံ့ ထောက်ပံ့ ထောက်ပံ့ ထောက်ပံ့ ထောက်ပံ့

အားလုံး အဆိုပါ ဘရပ်သျူ ဘရပ်အား ကူညီပေးသော cloneNode() အမှု ကို ထောက်ပံ့ပါသည်。