--- In [email protected], "Michael" <[EMAIL PROTECTED]> wrote:
<snip>

> I am trying to get the attribute names from mygroup...

<snip>

> 
> <mygroup id="1" task="do this">
>     <mychild id="1.1" task="do this" tools="hammer"/>
>     <mychild id="1.2" task="do this" tools="wrench"/>
> </mygroup>
> 

Suppose x:XML is the XML you show above. The "myChild" tags are
already accessible "as if" they were an array; for example, you can say

trace(x.myChild[0].toXMLString());

which will output

<mychild id="1.1" task="do this" tools="hammer"/>

Also, to access an attribute, you can use any of the following:

trace(x.myChild[0].attribute("id"));
trace([EMAIL PROTECTED]"id"]);
trace([EMAIL PROTECTED]);

all of which will output the string "1.1".

To use the XML as an array (sort of), you can use code such as:

for (i=0; i<x.myChild.length(); i++) {
     trace(i+" id "[EMAIL PROTECTED]);
}

x.myChild.length() returns the number of elements which are tags of
the type "myChild" (note the parens; it's ".length()", not ".length").

All this and more (e.g., the ability to only refer to myChild tags
which have the attribute tool=="hammer") can be found in the help docs
under:

Programming ActionScript 3.0 > Core ActionScript Data Types and
Classes > Working with XML 

Cheers - Chas





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to