Ah, like a true lambda expression -- good tip! ________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Tracy Spratt Sent: Thursday, November 06, 2008 3:46 PM To: [email protected] Subject: RE: [flexcoders] E4X equivalent to SQL where 'like %' expression ? If you need complex calculations within an e4x expression, you can call out to a function of your own. The () just requires a boolean value, so you can do something like below, where I wanted to a bit of string manipulation within the expression: xlFilteredItems = _xmlData..item.(itemContains(attribute("item"),sFilterString)) and the function: private function itemContains(sItem:String, sMatch:String):Boolean { sItem = sItem.toLowerCase(); sMatch = sMatch.toLowerCase(); return (sItem.indexOf(sMatch) != -1); }//itemContains Obviously you can do just about anything inside such a function including traversing the xml, and looping etc. Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Ryan Graham Sent: Thursday, November 06, 2008 5:07 PM To: [email protected] Subject: RE: [flexcoders] E4X equivalent to SQL where 'like %' expression ? Haha, looking at that, a more intuitive option would probably use the indexOf() function instead of substring, that way indexOf(input) == 0; //starts-with behavior indexOf(input) > -1; //contains behavior HTH, Ryan ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Ryan Graham Sent: Thursday, November 06, 2008 3:00 PM To: [email protected] Subject: RE: [flexcoders] E4X equivalent to SQL where 'like %' expression ? The child nodes can be accessed like properties. For a starts-with effect, you would use a similar expression that compares the what you want to search for with the equivalent substring of the name nodes in that list. You can get more complex and robust searches using string functions like toLowerCase or RegExps, but this will return the 2 emp nodes for Johnson and Jones given your input list: var input:String = "Jo"; trace(emplist.(name.substring(0, input.length) == input)); HTH, Ryan ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of pbrendanc Sent: Thursday, November 06, 2008 12:03 PM To: [email protected] Subject: [flexcoders] E4X equivalent to SQL where 'like %' expression ? I'd like to extract the list of emps from the following XML where name starts with 'Jo' (returns Jones, Johnson). In SQL I can use the expression 'where name like 'Jo%'. Anyone have examples of how this be done via an E4X expression (I could not find any examples of this in the docs). TIA, Patrick <mx:XMLList id="emplist"> <emp> <id>1</id> <name>Smith</name> <mrn>1000</mrn> <dob>1/1/1964</dob> </emp> <emp> <id>2</id> <name>Jones</name> <mrn>1001</mrn> <dob>11/11/1951</dob> </emp> <emp> <id>3</id> <name>Johnson</name> <mrn>1003</mrn> <dob>3/3/1953</dob> </emp> </mx:XMLList> This message is private and confidential. If you have received it in error, please notify the sender and remove it from your system. This message is private and confidential. If you have received it in error, please notify the sender and remove it from your system. This message is private and confidential. If you have received it in error, please notify the sender and remove it from your system.

