0 Replies Latest reply on May 6, 2010 11:11 PM by crissy84

    XML - Filtering on nested children

    crissy84 Level 1

      Hi,

       

      Let's say I have some XML like this...

       

      <cars>

           <car id="1">

             <options>

                  <option id="100"/>

                  <option id="200"/>

             </options>

           </car>

           <car id="2">

             <options>

                  <option id="100"/>

             </options>

           </car>

           <car id="3">
             <options>
                  <option id="200"/>
             </options>
           </car>

      </cars>

       

      I want to query for a list of all cars that have option #200.  Here's what I've tried.

       

      var list:XMLList = cars.car.(options.option.@id = 200)  // returns nothing

      var list:XMLList = cars.car.options.option.(@id = 200)  // returns option elements, not car elements of course

      var list:XMLList = cars.car.options.option.(@id = 200).parent().parent()  // throws an error

       

      How can I get the cars?  I've also tried getting the list of matching option elements, then manually looping over them and adding their parents to a new XMLListCollection... but performance was very bad (lots of elements)

       

      Any ideas?  Thanks!