Checkout the below code...this will ensure that you will get only ArrayCollection in both the cases...and also you need to check only once whether it is arrycollection or not and at other places you can avoid the check as you are converting it to ArrayCollection so you can directly use the arraycollection..
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="loadXMLData();" layout="absolute">
private var arrayCollection:ArrayCollection = new ArrayCollection();
private function loadXMLData():void
var xml:XML = new XML(myXml.toString());
var xmlDoc:XMLDocument = new XMLDocument(xml);
var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);
var resultObj:Object = decoder.decodeXML(xmlDoc);
if(resultObj != null)
if(resultObj.one.two is ArrayCollection)
arrayCollection = resultObj.one.two as ArrayCollection;
else if(resultObj.one.two is String)
<mx:XML id="myXml" xmlns="">
If this post answers your question or helps, please kindly mark it as such.
Thanks for the reply. I am already doing that, but it's horribly inconvenient because there are many many places where I have to have the same convoluted logic. There should be a global option when converting XML to always make Arrays.