User Guide

190 Server-Side ActionScript Language Reference
Example
The following example uses the XML.lastChild property to iterate through the child nodes
of an XMLNode object, starting with the last item in the nodes child list and ending with the
first child of the nodes child list:
// 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 lastChild to iterate through the child nodes of rootNode.
for (var aNode = rootNode.lastChild; aNode != null; aNode =
aNode.previousSibling) {
trace(aNode);
}
/*
output:
<youngest />
<middle />
<oldest />
*/
NOTE
In Flash Media Server, the output of trace() statements appears in the application log
file and Application inspector.