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.
xml_node->clonenode( true )
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>
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 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments