
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
119
// Assign the value of the 'order' attribute to variable z.
var z = doc.firstChild.attributes.order
trace(z);// output: first
XML.childNodes
my_xml.childNodes
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 read-only property cannot be used to manipulate child nodes. Use the
XML.appendChild(), XML.insertBefore(), and XML.removeNode() methods to manipulate child nodes.
This property is undefined for text nodes (
nodeType == 3).
Availability
Flash Media Server 2
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 = 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 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 = rootNode.childNodes;
trace(secondArray);
// Output: <oldest />,<middle />,<youngest />
See also
XML.nodeType
XML.cloneNode()
my_xml.cloneNode(deep)
Commenti su questo manuale