Thanks to both of you for your answers, this is exactly what I was
looking for.

I'm concerned about the performance and completeness of this solution
though, but it's *much* better than nothing. 

To give some more insight on what I intend to do with that (I'm still
evaluating): I'm currently wondering if it wouldn't be nice to use XML
object as model in my application. I really like the native support
for XML and the ease of traversing/querying data with E4X expressions.
The major problem I see with this approach is that it's maybe too
dynamic: handling change in the XML structure will require changes in
several places of my application (which would also be the case with a
classic object oriented model) but the compiler won't help me.

Anyway, one key aspect of using XML as model is to be able to use E4X
expressions at runtime. For instance I have a situation with two
datagrids, and I want the second datagrid data to be filtered
depending on the first datagrid selection. But the filter is business
oriented and business rules are on the server: so I can either call
the server whenever the selection change (uh, too bad in terms of user
experience) or store the filter expression in the data of the first
datagrid. Using an E4X expression as filter sounds flexible, powerful,
and easy enough. 

So that's one usage of the E4XParser, but I guess I can come up with
many others, this expression language is very powerful and easy to learn.

Thanks again for your help,

Xavier

--- In [email protected], "Seth Caldwell" <[EMAIL PROTECTED]> wrote:
>
> See http://www.adobe.com/devnet/flex/articles/e4x_04.html
> 
> Michael Labriola uses a custom function he wrote to do what you want
> (download the zip file attached to the tutorial):
> 
> E4XParser.evaluate( xml, string ) - that returns the evaluated
xml.string
> where string is an e4x expression.
> 
> What he uses it for is pretty cool too. Right now my application has
a few
> datagrids with a bunch of label functions.
> 
> I attacked the problem he used dynamic e4x to solve by instead using a
> function that returns a function, so even though my datagrids are
controlled
> by label functions, they're unique and the runtime should be a ton
better
> than this style of dynamic e4x evaluation. However, it is still
interesting
> =)
> 
>  
> 
> I'm curious about your requirement for dynamic e4x. Why do you need
it? I'd
> like to see a good use of it.
> 
>  
> 
> Seth
> 
>  
> 
>  
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of xhanin
> Sent: Thursday, January 17, 2008 2:49 AM
> To: [email protected]
> Subject: [flexcoders] Dynamic evaluation of E4X expression
> 
>  
> 
> Hi,
> 
> I find the E4X expression language very powerful, and would like to
> leverage it to find elements in an xml document.
> 
> The problem is that I get the E4X expression at runtime, so I'm
> looking for a way to dynamically invoke the E4X expression.
> 
> Something like:
> ------------------------------
> var myXML:XML = 
> <order>
> <item id='1'>
> <menuName>burger</menuName>
> <price>3.95</price>
> </item>
> <item id='2'>
> <menuName>fries</menuName>
> <price>1.45</price>
> </item>
> </order>;
> var expression:String = "item.(@id==2).menuName";
> 
> myXML.<something here?>(expression);
> ------------------------------
> 
> I first look for an eval function as in javascript, but found that AS3
> does not provide such function any more.
> 
> - Xavier
>


Reply via email to