childNodes (XMLNode.childNodes property)

public childNodes : Array [read-only]

An array of the specified XML object's children. Each element in the array is a reference to an XML object that represents a child node. This is a read-only property and cannot be used to manipulate child nodes. Use the appendChild(), insertBefore(), and removeNode() methods to manipulate child nodes.

This property is undefined for text nodes (nodeType == 3).

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)


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00002347.html