Try:

for each(var item:Object in nutritionXML[carousel].itemdata)



 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Jason B
Sent: Thursday, June 04, 2009 7:50 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] reference xml using variable dynamically

 






I'm using a e4x resultformat and returning from an httpservice a xml list of
items which works fine when i just use

for each(var item:Object in nutritionXML.breakfast.itemdata)

but if i try to do it dynamically it wont work?

//DYNAMICALLY
var carousel:String;

carousel = "breakfast"; 

for each(var item:Object in nutritionXML + [carousel].itemdata)
{


XML DATA RETURNED FROM HTTPSERVICE

<root>
<breakfast>
<itemdata>
<title>Oatmeal and Eggs Meal</title>
<imgsource>oatmeal_and_eggs_meal.jpg</imgsource>
<serving>1 cup oatmeal, 1 1/2 cups low fat milk|1 egg, 1 medium
banana</serving>
<cal>60</cal>
<swf>oatmeal_and_eggs_meal.swf</swf>
<available>yes</available>
</itemdata>
<itemdata>
<title>Shredded Wheat Meal</title>
<imgsource>shredded_wheat_breakfast.jpg</imgsource>
<serving>1 cup shredded wheat, 2/3 cup fat free yogurt|2 slices can. bacon,
1/2 cup orange juice</serving>
<cal>400</cal>
<swf>shredded_wheat_breakfast.swf</swf>
<available>yes</available>
</itemdata>



Reply via email to