Entry
How do I use the method copy?
How do I use the method copy?
Apr 10th, 2005 01:59
Martin Honnen,
The method copy takes no argument and returns a deep copy of the XML
object it is called on where the internal parent property is set to null.
Here are some examples using the method:
var god = <god>Kibo</god>;
var godCopy = god.copy();
alert(godCopy === god); // show false
alert(godCopy == god); // shows true
var gods = <gods>
<god>
<name>Kibo</name>
</god>
<god>
<name>Xibo</name>
</god>
</gods>;
var godCopy = gods.god[0].copy();
alert(godCopy);
/* shows
'<god>
<name>Kibo</name>
</god>'
*/
alert(gods.god[0].parent() === null); // shows 'false'
alert(godCopy.parent() === null); // shows 'true'