package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var cart:XML = <cart>
<item price=".98">crayons</item>
<item price="3.29">pencils</item>
<group>
<item price=".48">blue pen</item>
<item price=".48">black pen</item>
</group>
</cart>;
var total:Number = 0;
for each ( var price:XML in cart..@price ) {
total += price;
}
trace( total );
}
}
}
|