1 Reply Latest reply on Oct 7, 2009 7:06 AM by radikalFish

    Grouping items from parts of an XMLListCollection?

    Handycam Level 1

      I have made grouping collections before.  This is an odd case, though.


      I have an XMLListCollection called menuListCollection. Each member is something like this

      <?xml version="1.0" encoding="utf-8"?>
      <recipe course="starters">
      <title>Bacon-Wrapped Ginger Soy Scallops</title>
      <recipeLink>http://www.finecooking.com/recipes/bacon-wrapped-ginger-soy-scallops.aspx </recipeLink>
      <item qty=".25" units="cup" caption="soy sauce" desc="soy sauce" section="Other Groceries" />
      <item qty="1" units="Tbs." caption="dark brown sugar" desc="dark brown sugar" section="Pantry Staples" />
      <time label="1h"><instructions><![CDATA[none]]></instructions></time>
      <time label="45m"><instructions><![CDATA[Heat oven to 450°F for the Bacon-Wrapped Scallops.]]></instructions></time>
      <time label="30m"><instructions><![CDATA[Bake the Bacon-Wrapped Scallops and serve to guests to nibble while you make the final dinner preparations.]]></instructions></time>


      I need to work with these 3 bits: Title, RecipeLink, and Time -- grouped by label.  My goal is to easily have a listing of the instructions for all recipes grouped by time labels; that is, all the one hour instructions, all the 45 minute instructions, etc.


      Such as:


      1 Hour Before Dinner

        - instruction for recipe 1 that has this label

        - instruction for recipe 2 that has this label


      for each (var x:XML in menuListCollection){
      trace("30 minutes="+x..time.(@label=="30m").instructions.text());

      gives me

      title=Bacon-Wrapped Ginger Soy Scallops
      30 minutes=Bake the Bacon-Wrapped Scallops and serve to guests to nibble while you make the final dinner preparations.
      title=Beet Salad with Oregano, Pecans, and Goat Cheese
      30 minutes=Finish assembling the Beet Salad. 

      Is there an easy way to do this, or do I have to loop each item and make separate arrays?  I'd rather be able to use a grouping collection somehow.