0 Replies Latest reply on Mar 13, 2008 12:55 AM by leeng

    E4X predicate filtering

    leeng
      Hello,

      I have an XML file which consists of a list of classes and it's
      attributes (teacher, length, category, etc., etc., ...) Classes can
      belong to different depts. I want to be able to grab all the classes
      and their attributes that are part of a certain dept. The dept nodes
      is a child of the class node. I can filter out the xml file to find
      all the nodes whose dept value equals the dept I am looking for, but I
      don't know how to return the main parent node.

      here is the xml file :
      <klasses>
      <klass id="0">
      <title>klass A</title>
      <length unit="hr">1.5</length>
      <category>core</category>
      <depts>
      <dept>
      <name>art</name>
      </dept>
      <dept>
      <name>pe</name>
      </dept>
      <dept>
      <name>modeling</name>
      </dept>
      <dept>
      <name>animation</name>
      </dept>
      </depts>
      </klass>
      <klass id="1">
      <title>klass B</title>
      <length unit="hr">1.5</length>
      <category>core</category>
      <depts>
      <dept>
      <name>r and d</name>
      </dept>
      <dept>
      <name>td</name>
      </dept>
      <dept>
      <name>lighting</name>
      </dept>
      <dept>
      <name>matte painting</name>
      </dept>
      </depts>
      </klass>
      ...
      ...
      ...
      </klasses>


      I get the xml file from:
      courseList = evt.result.klass

      // I want to get all klass objects that has "art" as one of the
      dept.name nodes

      var needle:String = "art"

      I try using this predicate filter but it only returns a XMLLIst that
      consists of <name>needle</name>

      tempXMLList = courseList.klass.depts.dept.(name==needle)

      what I want returned is:
      <klass>
      ...
      ...
      ...
      </klass>
      <klass>
      ...
      ...
      ...
      </klass>
      ...
      ...
      ...

      where inside <klass> ... </klass> at least one of the dept.name nodes
      is equal to "art"

      I know it's probably simple but I can't seem to get the syntax right.
      I've looked at a lot of examples but they don;t make sense to me and
      most don't deal with anything deeper than a single level. I can't
      seem to find any good documentation on predicate filtering either. I
      appreciate any help, its kinda got me stuck from moving forward on
      this development project.

      I am still a novice on all this stuff.

      Thanks.

      be well,
      Hoyt