186
Server-Side ActionScript Language Reference
XML.hasChildNodes()
Availability
Flash Media Server 2.
Usage
my_xml
.hasChildNodes()
Parameters
None.
Returns
A Boolean value.
Description
Method; returns
true
if the specified XML object has child nodes;
false
otherwise.
Example
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.
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.n":\t"+aNode.firstChild.nodeValue);
}
}
}
The following output appears:
username:hank
password:rudolph