MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference page 1326

Actionscript 2.0 language reference
Table of Contents

Advertisement

// 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);
// 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
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)
,
method)
removeNode (XMLNode.removeNode method)
1326
ActionScript classes
XML.lastChild
,
insertBefore (XMLNode.insertBefore
,
XML
property to

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents