I have used parent().parent(). But Alex's expression looks better.
Also, remember that you can use a separate function (that returns a boolean) to perform more complex logic. I have found that this sometimes is easier to keep track of than trying to do the whole expression inline. Approach this one step at a time. Use some temporary XML and XMLList variables, be verbose in the expressions, and use toXMLString() at every step, making sure you have what you expect. Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of hoytlee2000 Sent: Friday, March 14, 2008 4:06 AM To: [email protected] Subject: [flexcoders] Re: need help with XML predicate filtering I tried that too and it came up empty too. I tried it without the klass node as I was miss reading the root, but that still didn't work. when I printout courseList.depts.dept.(name == needle) it returns all the name nodes like I expect but I want to get the klass node that is parented two levels up. Maybe it can't be done, most examples I've seen only return one parent node up from what they are searching for. be well, Hoyt --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Alex Harui" <[EMAIL PROTECTED]> wrote: > > Did you try: > > > > courseList.klass.(depts.dept.name==needle) > > > > ________________________________ > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of hoytlee2000 > Sent: Thursday, March 13, 2008 7:04 PM > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Re: need help with XML predicate filtering > > > > Hmmm ... doesn't seem to work. > > When I use the parent() method nothing is returned: > > tempXMLList = > courseList.klass.depts.dept.(name==needle).parent().parent() > > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%40yahoogroups.com> > , "Tracy Spratt" <tspratt@> wrote: > > > > Immediate parent. So that would be "depts". parent().parent() should > > return "klass" > > > > Tracy > > > > > > > > ________________________________ > > > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%40yahoogroups.com> > [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%40yahoogroups.com> > ] On > > Behalf Of hoytlee2000 > > Sent: Thursday, March 13, 2008 5:31 PM > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%40yahoogroups.com> > > Subject: [flexcoders] Re: need help with XML predicate filtering > > > > > > > > will that return it's immediate parent or the one all the way at the > > top? > > > > so tempXMLList = courseList.klass.depts.dept.(name==needle).parent() > > > > returns klass and not depts - right? > > > > Thanks, > > hoyt > > > > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders%40yahoogroups.com> > > , "Tracy Spratt" <tspratt@> wrote: > > > > > > .parent() will return the parent node. > > > > > > Tracy > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders%40yahoogroups.com> > > ] On > > > Behalf Of hoytlee2000 > > > Sent: Thursday, March 13, 2008 3:53 AM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders%40yahoogroups.com> > > > Subject: [flexcoders] need help with XML predicate filtering > > > > > > > > > > > > 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 > > > > > >

