AS3 with E4X / XML

[FONT=Arial]Hey guys,

I am working on a project that uses XML and up until this point, reading data from the XML file has been very easy. Unfortunately, I came across a problem that has me banging my head against a wall. So here is my issue.

I have a section of XML that I have setup as follows: (Note that I have removed some attributes for cleanliness)

<avatar>
<assets target=“hair”>
<asset id=“1000” src="/assets/boy/hair/boy_hair1.swf" gender=“m”/>
<asset id=“1502” src="/assets/girl/hair/girl_hair3.swf" gender=“f”/>
<asset id=“1503” src="/assets/girl/hair/girl_hair4.swf" gender=“f”/>
</assets>
<assets target=“head”>
<asset id=“2000” src="/assets/boy/head/boy_head.swf" gender=“m”/>
<asset id=“2503” src="/assets/girl/head/girl_head4.swf" gender=“f”/>
</assets>
</avatar>

Pretty simple so far right? Now, I actually have many more sets of assets, but I am just showing 2 here to keep things simple. All I want to do is simply obtain the first node of each set by specifying a gender. For example, if I want the first node for a female in each set, I would expect to retrieve asset id’s 1502 and 2503 in my XmlList. As simple as this sounds, I can’t seem to figure this out… Here is what I currently have:

var clothingList:XMLList = _avatarXml.assets.asset.(@gender == “f”);

This will give me all of the assets for each set that are female (1502, 1503, and 2503). However, I just want the first asset of each set based on the gender (1502, 2503). My initial thought was to do the following:

[/FONT][FONT=Arial]var clothingList:XMLList = _avatarXml.assets.asset.(@gender == _avatarVO.selectedGender)[0];

This returns an xml element though… the very first element period, and not the first element of each set. Please help me understand how I need to formulate this statement so that I get the first element of each set. Thanks!

Regards,

Will
[/FONT]