Faqts : Business : Programming : Shopping For You : JavaScript : XML : E4X (ECMAScript for XML) : XML objects

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 4 people (75%) answered Yes
Recently 3 of 4 people (75%) answered Yes

Entry

How do I use the method copy?
How do I use the method copy?

Apr 10th, 2005 01:59
Shopping Snooper, Casino Vendor Directory, 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'