User Guide
XML class 199
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 ASC file:
var my_xml = new XML("<login><username>hank</username>
<password>rudolph</password></login>");
if (my_xml.firstChild.hasChildNodes()) {
// Use firstChild to iterate through the child nodes of rootNode.
for (var aNode = my_xml.firstChild.firstChild; aNode != null;
aNode=aNode.nextSibling) {
if (aNode.nodeType == 1) {
trace(aNode.nodeName+":\t"+aNode.firstChild.nodeValue);
}
}
}
The following node names appear:
username:hank
password:rudolph
See also
XML.nodeType
XML.nodeType
Availability
Flash Media Server 2.
Usage
my_xml.nodeType
Description
Property (read-only); a nodeType value, either 1 for an XML element or 3 for a text node.
The
nodeType is a numeric value from the NodeType enumeration in the W3C DOM Level
1 Recommendation. The following table lists the values:
NOTE
In Flash Media Server, the output of trace() statements appears in the application log
file and Application inspector.
Integer value Defined constant
1
ELEMENT_NODE
2
ATTRIBUTE_NODE
3
TEXT_NODE