
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
120
Constructs and returns a new XMLNode object of the same type, name, Administration Console 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 have a value of null. If the deep parameter is set to false, or
if
my_xml has no child nodes, firstChild and lastChild are also null.
Availability
Flash Media Server 2
Parameters
deep A boolean value; if set to true, the children of the specified XML object will be recursively cloned; otherwise,
false.
Returns
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 = new XML();
// Create a root node.
var rootNode = doc.createElement("rootNode");
// Create three child nodes.
var oldest = doc.createElement("oldest");
var middle = doc.createElement("middle");
var youngest = 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 by using cloneNode().
var middle2 = middle.cloneNode(false);
// Insert the clone node into rootNode between
// the middle and youngest nodes.
rootNode.insertBefore(middle2, youngest);
trace(rootNode);
// Output (with line breaks added):
// <rootNode>
//<oldest />
//<middle />
//<middle />
//<youngest />
// </rootNode>
// Create a copy of rootNode by using cloneNode() to demonstrate a deep copy.
var rootClone = rootNode.cloneNode(true);
Komentarze do niniejszej Instrukcji