User Guide
1324 ActionScript classes
trace(xmlDoc.getPrefixForNamespace("http://www.example.com/util")); //
output: exu
trace(xmlDoc.getPrefixForNamespace("http://www.example.com/other")); //
output: null
var child1:XMLNode = xmlDoc.firstChild;
trace(child1.getPrefixForNamespace("http://www.example.com/child")); //
output: [empty string]
trace(child1.getPrefixForNamespace("http://www.example.com/other")); //
output: null
See also
getNamespaceForPrefix (XMLNode.getNamespaceForPrefix method), namespaceURI
(XMLNode.namespaceURI property)
hasChildNodes (XMLNode.hasChildNodes method)
public hasChildNodes() : Boolean
Specifies whether or not the XML object has child nodes.
Availability: ActionScript 1.0; Flash Player 5
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