XMLNode
749
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:XMLNode = rootNode.lastChild; aNode != null; aNode =
aNode.previousSibling) {
trace(aNode);
}
// output:
// <youngest />
// <middle />
// <oldest />
The following example creates a new XML packet and uses the
XML.lastChild
property to
iterate through the child nodes of the root node:
// create a new XML document
var doc:XML = new XML("");
var rootNode:XMLNode = doc.firstChild;
// use lastChild to iterate through the child nodes of rootNode
for (var aNode:XMLNode = rootNode.lastChild; aNode != null;
aNode=aNode.previousSibling) {
trace(aNode);
}
// output:
// <youngest />
// <middle />
// <oldest />
See also
appendChild (XMLNode.appendChild method)
,
insertBefore (XMLNode.insertBefore
method)
,
removeNode (XMLNode.removeNode method)
,
XML
Summary of Contents for Flash Lite 2
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...