744
ActionScript classes
cloneNode (XMLNode.cloneNode method)
public cloneNode(deep:
Boolean
) : XMLNode
Constructs and returns a new XML node of the same type, name, value, and attributes as the
specified XML object. If
deep
is set to
true
, all child nodes are recursively cloned, resulting in
an exact copy of the original object's document tree.
The clone of the node that is returned is no longer associated with the tree of the cloned item.
Consequently,
nextSibling
,
parentNode
, and
previousSibling
all have a value of
null
. If
the
deep
parameter is set to
false
, or the
my_xml
node has no child nodes,
firstChild
and
lastChild
are also null.
Availability:
ActionScript 1.0; Flash Lite 2.0
Parameters
deep
:
Boolean
- A Boolean value; if set to
true
, the children of the specified XML object will
be recursively cloned.
Returns
XMLNode
- An XMLNode Object.
Example
The following example shows how to use the
XML.cloneNode()
method to create a copy of a
node:
// create a new XML document
var doc:XML = new XML();
// create a root node
var rootNode:XMLNode = doc.createElement("rootNode");
// create three child nodes
var oldest:XMLNode = doc.createElement("oldest");
var middle:XMLNode = doc.createElement("middle");
var youngest:XMLNode = doc.createElement("youngest");
// add the rootNode as the root of the XML document tree
doc.appendChild(rootNode);
// add each of the child nodes as children of rootNode
rootNode.appendChild(oldest);
rootNode.appendChild(middle);
rootNode.appendChild(youngest);
// create a copy of the middle node using cloneNode()
var middle2:XMLNode = middle.cloneNode(false);
Summary of Contents for Flash Lite 2
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...