ActionScript3: How to seach an XML list?

Zepillide

New Member
I have the following XML variable:\[code\]public var Country:XML=new XML( <countries> <country code="US" iso="840" label="United States" /> <country code="CA" iso="124" label="Canada" /> <country code="GB" iso="826" label="United Kingdom" /> ... </countries>);\[/code\]How would I loop through the list to find the index number corresponding to the value stored in String variable \[code\]myCountry\[/code\]? For example, if \[code\]var myCountry:String = "Canada";\[/code\]How to create a loop that returns an index value of 1, meaning Canada is the 2nd element in the XML list? Or, maybe looping isn't necessary if the index value of 1 can be returned some other way. I tried:\[code\]var desiredIndex:int = Country.country.(@label==myCountry)\[/code\]but it gives the error \[code\]No such variable: @label\[/code\].
 
Back
Top