1318
ActionScript classes
Availability:
ActionScript 1.0; Flash Player 5
Example
The following example shows how to use the XML.childNodes property to return an array of
child nodes:
// 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 an array and use rootNode to populate it
var firstArray:Array = doc.childNodes;
trace (firstArray);
// output: <rootNode><oldest /><middle /><youngest /></rootNode>
// create another array and use the child nodes to populate it
var secondArray:Array = rootNode.childNodes;
trace(secondArray);
// output: <oldest />,<middle />,<youngest />
See also
nodeType (XMLNode.nodeType property)
,
appendChild (XMLNode.appendChild
method)
,
insertBefore (XMLNode.insertBefore method)
,
removeNode
(XMLNode.removeNode method)
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.
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...