Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > XMLNode > hasChildNodes (XMLNode.hasChildNodes method) | |||
public hasChildNodes() : Boolean
Specifies whether or not the XML object has child nodes.
Availability: ActionScript 1.0; Flash Player 5
Boolean - true if the specified XMLNode has one or more child nodes; otherwise false.
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
Flash CS3
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00002352.html
Comments
gaw.in said on Sep 11, 2007 at 9:08 PM :