On thing that trips up a lot of folks is that the default resultFormat
of the RPC protocols is "object".  This causes the result xml to be
converted to a nested object structure, which converts xml lists to
arrays of objects.  Using mx:Model does the same thing.  So an
expression like "xmldata. items.item" can work "acidentally", because
you do not reallly have xml.  

 

I advise always using resultFormat="e4x" and mx:XML.

 

Now, doing that, you don't get an automatic array you can use as a
source for an ArrayCollection.  You have to manually build that array.
There might be a method in one of the Util classes that would help, but
I don't know it.

 

Are you certain you need an ArrayCollection?  XMLListCollection gives
you the same API functionality, without the requirement to manually
build a source Array. An XMLList can be wrapped directly.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Sherif Abdou
Sent: Sunday, January 27, 2008 10:30 AM
To: [email protected]
Subject: Re: [flexcoders] XML to ArrayCollection

 

I think you may have to iterate for the Child nodes but try

ArrayUtil.toArray(xmldata.items.item);

----- Original Message ----
From: M.Javed <[EMAIL PROTECTED]>
To: [email protected]
Sent: Sunday, January 27, 2008 7:26:56 AM
Subject: [flexcoders] XML to ArrayCollection

Hi,

 

I have to convert from XML or XMLList to ArracyCollection. I have found
an example but its not working, example is pasted below,

------------ --------- --------- --------- --------- --------- ---------
--------

<mx:ArrayCollection id="myAC" source="{xmldata. items.item} "/>

The value for source is the name of the model (xmldata), the name of the
XML's root node (items in this example) and the child node that the
array will be based on (item).
------------ --------- --------- --------- --------- --------- ---------
--------

I am doing exactly the same thing but its giving runtime error "cannot
convert XMLList to Array".

 

Any idea how to achive that?? or I have to manually Iterate on each node
of XML to fill the array.???

 

________________________________

Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try
it now.
<http://us.rd.yahoo.com/evt=51733/*http:/mobile.yahoo.com/;_ylt=Ahu06i62
sR8HDtDypao8Wcj9tAcJ>  

 

 

________________________________

Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try
it now.
<http://us.rd.yahoo.com/evt=51733/*http:/mobile.yahoo.com/;_ylt=Ahu06i62
sR8HDtDypao8Wcj9tAcJ%20> 

 

Reply via email to