एक्सएमएल डोम क्लोननोड () विधि
नोड वस्तु
उदाहरण
निम्न कोड खंड " 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);
//
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
परिभाषा और उपयोग
क्लोन नोड () विधि एक नोड की एक प्रति बनाता है, और नया क्लोन नोड लौटाता है।
ब्राउज़र समर्थन
क्लोनोड () विधि सभी प्रमुख ब्राउज़रों में समर्थित है।
वाक्य - विन्यास
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 |
टेक्निकल डिटेल
डोम संस्करण | कोर स्तर 1 नोड वस्तु |
---|
नोड वस्तु