RE: [flexcoders] Re: e4x XML question - possible bug?
I haven't tried it, but I think you should be able to use predicate filtering with a variable. XML and XMLList instances have child(name) and attribute(name) methods for accessing a child element or an attribute whose name may not be known until runtime. In other words, x.employee.(name == McGee) should be the same as x.employee.(child(name) == McGee) so instead of x.employee.([whichProperty] == whichValue) try x.employee.(child(whichProperty) == whichValue) - Gordon -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Matt Chotin Sent: Thursday, February 09, 2006 11:27 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Re: e4x XML question - possible bug? I'm not sure the filtering predicate operator will work for a variable. I think you're going to need to do this instead: var matches:XMLList = new XMLList(); var i:int = 0; for each (var emp:XML in x.employee) { if (emp[testVar] == testValue) { matches[i++] = emp; } } The e4x compiler is going to generate code similar to this, so I don't think we're doing anything too inefficient here. Matt -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of thunderstumpgesatwork Sent: Thursday, February 09, 2006 9:41 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: e4x XML question - possible bug? Good thought, and I saw this suggestion in another related post, however this always returns an empty list. Is this possibly a bug? Do you know that this should in fact work? I have not seen any documentation stating that it should or shouldn't. thanks, Thunder --- In flexcoders@yahoogroups.com, Manish Jethani [EMAIL PROTECTED] wrote: On 2/8/06, thunderstumpgesatwork [EMAIL PROTECTED] wrote: x.employee.(lastName == McGee) // nodes with lastName McGee I need to do this dynamically.. what if I don't know the element name (the 'lastName' portion above) ? How can I substitute a String variable for the 'lastName' ? Try this: x.employee.([variable] == McGee) -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
[flexcoders] Re: e4x XML question - possible bug?
Dang! I thought for sure this would work... such a good idea. Unfortunately with this syntax the compiler throws an error: Call to a possibly undefined method 'child' Note the first thing I did was make sure I was in fact using an XMLList variable, and that the child method was defined.. Darn... I guess for now its just going to take a custom filtering function. Maybe someday later we can use the predicate filtering syntax with a variable. Thanks guys for trying! Thunder --- In flexcoders@yahoogroups.com, Gordon Smith [EMAIL PROTECTED] wrote: I haven't tried it, but I think you should be able to use predicate filtering with a variable. XML and XMLList instances have child(name) and attribute(name) methods for accessing a child element or an attribute whose name may not be known until runtime. In other words, x.employee.(name == McGee) should be the same as x.employee.(child(name) == McGee) so instead of x.employee.([whichProperty] == whichValue) try x.employee.(child(whichProperty) == whichValue) - Gordon -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Matt Chotin Sent: Thursday, February 09, 2006 11:27 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Re: e4x XML question - possible bug? I'm not sure the filtering predicate operator will work for a variable. I think you're going to need to do this instead: var matches:XMLList = new XMLList(); var i:int = 0; for each (var emp:XML in x.employee) { if (emp[testVar] == testValue) { matches[i++] = emp; } } The e4x compiler is going to generate code similar to this, so I don't think we're doing anything too inefficient here. Matt -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of thunderstumpgesatwork Sent: Thursday, February 09, 2006 9:41 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: e4x XML question - possible bug? Good thought, and I saw this suggestion in another related post, however this always returns an empty list. Is this possibly a bug? Do you know that this should in fact work? I have not seen any documentation stating that it should or shouldn't. thanks, Thunder --- In flexcoders@yahoogroups.com, Manish Jethani manish.jethani@ wrote: On 2/8/06, thunderstumpgesatwork thunder.stumpges@ wrote: x.employee.(lastName == McGee) // nodes with lastName McGee I need to do this dynamically.. what if I don't know the element name (the 'lastName' portion above) ? How can I substitute a String variable for the 'lastName' ? Try this: x.employee.([variable] == McGee) -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
[flexcoders] Re: e4x XML question - possible bug?
Good thought, and I saw this suggestion in another related post, however this always returns an empty list. Is this possibly a bug? Do you know that this should in fact work? I have not seen any documentation stating that it should or shouldn't. thanks, Thunder --- In flexcoders@yahoogroups.com, Manish Jethani [EMAIL PROTECTED] wrote: On 2/8/06, thunderstumpgesatwork [EMAIL PROTECTED] wrote: x.employee.(lastName == McGee) // nodes with lastName McGee I need to do this dynamically.. what if I don't know the element name (the 'lastName' portion above) ? How can I substitute a String variable for the 'lastName' ? Try this: x.employee.([variable] == McGee) -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
RE: [flexcoders] Re: e4x XML question - possible bug?
I'm not sure the filtering predicate operator will work for a variable. I think you're going to need to do this instead: var matches:XMLList = new XMLList(); var i:int = 0; for each (var emp:XML in x.employee) { if (emp[testVar] == testValue) { matches[i++] = emp; } } The e4x compiler is going to generate code similar to this, so I don't think we're doing anything too inefficient here. Matt -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of thunderstumpgesatwork Sent: Thursday, February 09, 2006 9:41 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: e4x XML question - possible bug? Good thought, and I saw this suggestion in another related post, however this always returns an empty list. Is this possibly a bug? Do you know that this should in fact work? I have not seen any documentation stating that it should or shouldn't. thanks, Thunder --- In flexcoders@yahoogroups.com, Manish Jethani [EMAIL PROTECTED] wrote: On 2/8/06, thunderstumpgesatwork [EMAIL PROTECTED] wrote: x.employee.(lastName == McGee) // nodes with lastName McGee I need to do this dynamically.. what if I don't know the element name (the 'lastName' portion above) ? How can I substitute a String variable for the 'lastName' ? Try this: x.employee.([variable] == McGee) -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/