User Guide

XMLNode 747
See also
appendChild (XMLNode.appendChild method), insertBefore (XMLNode.insertBefore
method)
, removeNode (XMLNode.removeNode method)
hasChildNodes (XMLNode.hasChildNodes method)
public hasChildNodes() : Boolean
Specifies whether or not the XML object has child nodes.
Availability: ActionScript 1.0; Flash Lite 2.0
Returns
Boolean - true if the specified XMLNode has one or more child nodes; otherwise false.
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. 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 is displayed in the Output panel:
output:
username: hank
password: rudolph
insertBefore (XMLNode.insertBefore method)
public insertBefore(newChild:XMLNode, insertPoint:XMLNode) : Void
Inserts a newChild node into the XML object's child list, before the insertPoint node. If
insertPoint is not a child of the XMLNode object, the insertion fails.
Availability: ActionScript 1.0; Flash Lite 2.0