AS3 - Reading the first element from XML


I loaded XML in AS3. In that XML, I make that flash will retrieving a value of an attribute and traced it. the output was:


But I want that flash will output only the first element from that output (test1 only). I searched in Google and I didn't find an answer.

Sample of my XML content :

    <myXML typesId="test1,test2,test3,test4"/>

You can extract the first word (test1) from the typesId parameter using String.substr() function :

var xml:XML = <data>
    <myXML typesId="test1,test2,test3,test4"/>

var types:String = [email protected];

trace(types.substr(0, types.indexOf(',')));     // gives : test1

Hope that can help.