How to get Total Number of XML Nodes?
Hello All,
I have a Flash program I'm doing in Actionscript 3, using CS6.
I'm using the XMLSocket Class to read-in XML Data. I will write some sample XML Data that is being sent to the Flash
program below...
I know with this line here (below) I can access the 4th "element or node" of that XML Data.
Accessing XML Nodes/Elements:
// *I created an XML Variable called xml, and "e.data" contains ALL the XML Data
var xml:XML = XML(e.data);// Accessing the 4th element of the data:
xml.MESSAGE[3].@VAR; ---> "loggedOutUsers"
xml.MESSAGE[3].@TEXT; ---> "15"
SAMPLE XML DATA:
<FRAME>
0 <MESSAGE VAR="screen2Display" TEXT="FRAME_1"/>
1 <MESSAGE VAR="numUsers" TEXT="27"/>
2 <MESSAGE VAR="loggedInUsers" TEXT="12"/>
3 <MESSAGE VAR="loggedOutUsers" TEXT="15"/>
4 <MESSAGE VAR="admins" TEXT="2"/>
</FRAME>
I'm new to Flash and Actionscript but I'm very familiar with other languages and how arrays work and such, and I know for
example, in a Shell Script to get the total number of elements in an array called "myArray" I would write something like
this --> ${#myArray[@]}. And since processing the XML Data looks an awful lot like an array I figured there was maybe
some way of accessing the total number of "elements/nodes" in the XML Data...?
Any thoughts would be much appreciated!
Thanks in Advance,
Matt