XML DOM cloneNode() နည်းလမ်း
❮ Node Object
ဥပမာ
အောက်ဖော်ပြပါ ကုဒ်အပိုင်းအစသည် " books.xml " ကို load လုပ်သည်၊ ပထမ <book> 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, y, cloneNode, i, xmlDoc, txt;
xmlDoc = xml.responseXML;
txt = "";
x = xmlDoc.getElementsByTagName('book')[0];
cloneNode
= x.cloneNode(true);
xmlDoc.documentElement.appendChild(cloneNode);
//
Output all titles
y = xmlDoc.getElementsByTagName("title");
for (i = 0; i < y.length; i++) {
txt += y[i].childNodes[0].nodeValue + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
Everyday Italian
Harry Potter
XQuery Kick Start
Learning XML
Everyday Italian
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
cloneNode() နည်းလမ်းသည် node တစ်ခု၏ မိတ္တူကို ဖန်တီးပြီး အသစ်သော clone node ကို ပြန်ပေးသည်။
Browser ပံ့ပိုးမှု
cloneNode() နည်းလမ်းကို အဓိက ဘရောက်ဆာအားလုံးတွင် ပံ့ပိုးထားသည်။
အထားအသို
nodeObject.cloneNode(deep)
ကန့်သတ်ချက်များ
Parameter | Type | Description |
---|---|---|
deep | Boolean | true clones the node, its attributes, and its descendants.
false clones the node and its attributes. |
တန်ဖိုးကို ပြန်ပေးသည်။
Type | Description |
---|---|
Node object | The cloned node |
နည်းပညာဆိုင်ရာအသေးစိတ်
DOM ဗားရှင်း | Core Level 1 Node Object |
---|
❮ Node Object