In Flex, it's easy to convert the XML to Object and to ArrayCollection by using
var decoder:SimpleXMLDecoder = new SimpleXMLDecoder();
decoder.decodeXML( xml );
But is there a good way to convert ArrayCollection to XML.
I have search a while on the internet and havn't found any answer.
Thanks.
Best Answer
Have a look at this example, which uses SimpleXMLEncoder:
...which produces the following XML:
I should note that got the objectToXML function from Peter de Haan's blog, but folks have apparently had a few problems with the SimpleXMLEncoder class. In my own tests, encoding simple objects works well (as indicated above), but complex types tend to produce unpredictable results. (For example, encoding an array of Font objects produced a long list of empty item nodes.)
But depending on the types you're attempting to serialize, this approach might work out just fine for you. Hope it helps!