Flex Webservices XML and Array Conversion
I'm currently working on a project involving simple webservices, the webservices return plain XML rather than using SOAP. Personally I prefer SOAP as you get a well defined interface but on this project it was felt that plain XML was less verbose, more efficient and easy to code server side.
Anyway one of the issues with returning XML via HTTPService calls is that when flex converts the XML to objects it treats it as array if there's more than one item of the same name but as a single item (ie not an array) if there's only one item of the same name.
This causes databinding to datagrids or lists to fail.
So how do you get around this issue?
TweetBacks
var data:Object = event.result.users.user
if (data is ArrayCollection) {
userlist = ArrayCollection(data);
}
else {
userlist = new ArrayCollection([data])
}