RE: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-23 Thread Tracy Spratt
). "parent()" would pass the parent node etc. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mark Carter Sent: Monday, September 22, 2008 11:45 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] e4x problem

RE: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Mark Carter
Oops - missed out a check on the match: // assuming filters are lower case and distinct... private function nameElementsContainAll(nameElements:XMLList, filters:Array):Boolean { var matchedFilters:Array = new Array(); for each (var nameElement:XML in nameElements) { var matchInde

RE: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Mark Carter
Thanks - thats very useful - hadn't thought of that. Assumed it would not be possible. Whats the best way to get a handle on the item element from within the itemContains function? I would probably go with this approach: xlFilteredItems = _xmlData..group.(nameElementsContainAll(name,filters));

RE: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Tracy Spratt
filtering elements based on multiple child conditions It seems to work it out for you when it can. name.text()[0].toLowerCase() works name.text().toLowerCase() also works if there is exactly one name child of each group element. Daniel Freiman wrote: > > name.text()[0] will give you a single

Re: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Mark Carter
It seems to work it out for you when it can. name.text()[0].toLowerCase() works name.text().toLowerCase() also works if there is exactly one name child of each group element. Daniel Freiman wrote: > > name.text()[0] will give you a single XML node of Kind string. If you > want > to operate on

Re: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Daniel Freiman
name.text()[0] will give you a single XML node of Kind string. If you want to operate on it as a string simply do: name.text()[0].toString() On Mon, Sep 22, 2008 at 11:35 AM, Mark Carter <[EMAIL PROTECTED]> wrote: > > I get "value is not a function" - I guess because toLowerCase() cannot work >

Re: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Mark Carter
I get "value is not a function" - I guess because toLowerCase() cannot work on an XMLList. You would have to do: rootXML.group.(name.text()[0].toLowerCase()=="fred"&&name.text()[0].toLowerCase()=="bob") which, like you say, would always return nothing. Or you have to specify group elements wit

Re: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Mark Carter
Nice. I see what you've done there (instead of "var result:XMLList = rootXML.group.name;" as the first line which would have been rather inefficient). I suppose this general approach doesnt work if I want to do things like lowercase or substring matching...? Daniel Freiman wrote: > > You're co

Re: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Daniel Freiman
I think you'd actually be matching "fred" against the first item in the list, which would means that the entire expression would always return false because the first item can't be both "bob" and "fred". On Mon, Sep 22, 2008 at 11:05 AM, Mark Carter <[EMAIL PROTECTED]> wrote: > > That doesnt work

Re: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Mark Carter
That doesnt work for me. Arent you trying to match "fred" against the lowercased name.text() XMLList? xitij2000 wrote: > > i performed a similar operation by doing: > rootXML.group.(name.text().toLowerCase()=="fred"&&name.text().toLowerCase()=="bob") > > the toLowerCase is just because i neede

Re: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Daniel Freiman
You're correct, but you can also do the filtering in a loop to be dynamic: var result:XMLList = rootXML.group.(name.text().contains("fred")); for each (filterName) { // psuedo-code result = result.(name.text().contains(filterName)); } return result; - Daniel Freiman On Mon, Sep 22, 2008 at 10

Re: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Mark Carter
Oh cool, that works, thanks very much Daniel. Am I right in thinking that "name.text()" is returning an XMLList of text nodes and "contains(fred)" is basically looking for a match of "fred" in that list? In real life, instead of having two names, I have an array of names. I suppose its not possi

Re: [flexcoders] e4x problem - filtering elements based on multiple child conditions

2008-09-22 Thread Daniel Freiman
try this: rootXML.group.(name.text().contains("fred") && name.text().contains("bob")) - Daniel Freiman On Mon, Sep 22, 2008 at 5:20 AM, Mark Carter <[EMAIL PROTECTED]> wrote: > > Ok, that subject is a bit vague but here's an example of what I mean: > > > fred > bob > peter > > > Say we have l