MACROMEDIA FLASHLITE2 ACTIONSCRIPT-LANGUAGE Reference page 751

Actionscript language reference
Table of Contents

Advertisement

Example
The following example creates an element node and a text node, and checks the node name
of each:
// create an XML document
var doc:XML = new XML();
// create an XML node using createElement()
var myNode:XMLNode = doc.createElement("rootNode");
// place the new node into the XML tree
doc.appendChild(myNode);
// create an XML text node using createTextNode()
var myTextNode:XMLNode = doc.createTextNode("textNode");
// place the new node into the XML tree
myNode.appendChild(myTextNode);
trace(myNode.nodeName);
trace(myTextNode.nodeName);
// output:
// rootNode
// null
The following example creates a new XML packet. If the root node has child nodes, the code
loops over each child node to display the name and value of the node. Add the following
ActionScript to your FLA or AS file:
var my_xml:XML = new XML("hankrudolph");
if (my_xml.firstChild.hasChildNodes()) {
// use firstChild to iterate through the child nodes of rootNode
for (var aNode:XMLNode = my_xml.firstChild.firstChild; aNode != null;
aNode=aNode.nextSibling) {
if (aNode.nodeType == 1) {
trace(aNode.nodeName+":\t"+aNode.firstChild.nodeValue);
}
}
}
The following node names are displayed in the Output panel:
output:
username: hank
password: rudolph
See also
nodeType (XMLNode.nodeType property)
XMLNode
751

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASHLITE2 ACTIONSCRIPT-LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash lite 2

Table of Contents