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