Lasso Soft Inc. > Home

[ xml_node->clonenode ]

Method

The [xml_node->clonenode] method creates a duplicate of the supplied xml_node.

This method requires one true/false parameter which instructs the method to return the node without or with the original node's child elements. ie. setting the parameter to True returns an empty copy of the node with the same attributes as the original; setting the parameter to false returns a complete copy of the original node.

  • Syntax
xml_node->clonenode( true )
Examples
  • Beginner

Create a copy of an existing xml_node

This example uses the [xml_node->clonenode] method to add two copies of a node to an xml_node. Note the difference in the results when the parameter is True or False.

Code

var( rhino = xml('<rhino class="coder">Jono</rhino>'),
     rhinos = xml('<rhinos></rhinos>') )

with x in array(true,false) 
     do => {
          local( 'cloneNode' = $rhino->cloneNode(#x) )
          $rhinos->appendchild(#cloneNode)
     }
     
$rhinos

Result

<rhinos>
  <rhino class="coder"/>
  <rhino class="coder">Jono</rhino>
</rhinos>

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft