views:

556

answers:

1

Hi,

I'm trying to use e4x to retrieve xml from the result event thrown when my Flex webservice is successful.

This is a snippet of the returned xml

<p430:getRoomsResponse xmlns:p430="http://impl.service.com"&gt;
 <p430:getRoomReturn type="p888:Room" xmlns:p888="http://vo.room.com" xmlns="http://www.w3.org/2001/XMLSchema-instance"&gt;    <p888:roomName>  ABC
    </p888:roomName>
    <p888:roomSize>
      200sqft
    </p888:roomSize>

The full xml contains approx 40 of these "ROOM" types containing roomname,size etc.

I want to create a collection containing a list of the 40 room objects based on the xml above.

How can I map the objects from my xml to an object using e4x?

The purpose is to display the objects in a datagrid

Thanks

A: 

http://blog.flexexamples.com/2007/07/26/displaying-xml-data-in-a-datagrid/

Create an XMLListCollection based on your XML and use that as the dataprovider. This might be the simplest way. I don't know of any XML -> JSON converters offhand, besides writing a manual one yourself. (e.g., iterate all your rooms and build your object by hand. )

Glenn