XML class
181
XML.firstChild
Availability
Flash Media Server 2.
Usage
my_xml
.firstChild
Description
Property (read-only); evaluates the specified XML object and references the first child in the
parent node’s child list. This property is
null
if the node does not have children. This
property is
null
if the node is a text 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.
Example
The following example shows how to use
XML.firstChild
to loop through a node’s 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);
// Use firstChild to iterate through the child nodes of rootNode.
for (var aNode = rootNode.firstChild; aNode != null; aNode =
aNode.nextSibling) {
trace(aNode);
}
// Output:
// <oldest />