If you leave the resultFormat as the default "object", then Flex will
convert the xml into a nested object tree automatically.  But this is
not a very good way to do this.

 

If you are sure you do not want to work directly with XML and
XMLListCollection (there are pros and cons), then your best bet will be
to:

1) Define a class with strongly typed public properties to hold your
item data (VO)

2) Set resultFormat="e4x" to prevent Flex from converting your data.

3) In the handler, convert event.result to xml:var myXML:XML =
XML(event.result);

3) Using an e4x expression on the xmlResult, get your items in an
XMLList.

4) for-loop over the XMLList, instanitating a new VO, and assigning the
values from the XMLnode to the appropriate VO property

5) Push that onto a temporary array

6) Create a new ArrayCollection() from the temporary array.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Dave Kong
Sent: Tuesday, June 03, 2008 10:20 PM
To: [email protected]
Subject: [flexcoders] How to convert an e4x XML object into an AS
object?

 

I know SimpleXMLDecoder can decode a legacy XMLNode to an object and
make good guesses at basic types such as string vs. int. But if I have
the new e4x XML object, how do I easily convert that to objects? Or
convert from E4X to XMLNode?

 

Reply via email to