E4X Tip: Array of attribute values with one line of code
Task – to get a list of node IDs from an XML doc without using a for loop
Given the following bit of XML -
<item id="15" />
<item id="16" />
<item id="17" />
<item id="18" />
<item id="19" />
<item id="20" />
var list:Array = [];
xmlData.item.( list.push( @id ) );
trace( list ) // 15, 16, 17, 18, 19, 20
It’s simple as that – no loops, nothing!
Leave a comment if you found this useful.
Comments
Leave a Reply
