
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
129
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 node’s child list and ending with the first child of the node’s 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 />
*/
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 = new XML("<rootNode><oldest /><middle /><youngest /></rootNode>");
var rootNode = doc.firstChild;
// 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 />
*/
XML.load()
my_xml.load(url)
Commenti su questo manuale