XMLNode
741
Parameters
newChild
:
XMLNode
- An XMLNode that represents the node to be moved from its current
location to the child list of the
my_xml
object.
Example
This example does the following things in the order shown:
■
Creates two empty XML documents,
doc1
and
doc2
.
■
Creates a new node using the
createElement()
method, and appends it, using the
appendChild()
method, to the XML document named
doc1
.
■
Shows how to move a node using the
appendChild()
method, by moving the root node
from
doc1
to
doc2
.
■
Clones the root node from
doc2
and appends it to
doc1
.
■
Creates a new node and appends it to the root node of the XML document
doc1
.
var doc1:XML = new XML();
var doc2:XML = new XML();
// create a root node and add it to doc1
var rootnode:XMLNode = doc1.createElement("root");
doc1.appendChild(rootnode);
trace ("doc1: " + doc1); // output: doc1: <root />
trace ("doc2: " + doc2); // output: doc2:
// move the root node to doc2
doc2.appendChild(rootnode);
trace ("doc1: " + doc1); // output: doc1:
trace ("doc2: " + doc2); // output: doc2: <root />
// clone the root node and append it to doc1
var clone:XMLNode = doc2.firstChild.cloneNode(true);
doc1.appendChild(clone);
trace ("doc1: " + doc1); // output: doc1: <root />
trace ("doc2: " + doc2); // output: doc2: <root />
// create a new node to append to root node (named clone) of doc1
var newNode:XMLNode = doc1.createElement("newbie");
clone.appendChild(newNode);
trace ("doc1: " + doc1); // output: doc1: <root><newbie /></root>
Summary of Contents for FLASHLITE2 ACTIONSCRIPT-LANGUAGE
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...