Over the weekend I was writing a simple little app, and came across something that should have been trivial, but turned out to throw me for a loop momentarily. I needed to drive some data from XML instead of my tried-and-true ColdFusion components, and I realized I’d never done it before. So, here’s the example:
First off, you need to actually get the XML file using a HTTPService:
Looks simple enough, but to produce valid XML, I needed to have a root node around my other nodes:
Now, when I put this directly into a XMLList object, I got a ComboBox with one option… my entire XML packet. It took a few tries to realize that I needed to make the DataProvider only the “variety” nodes, and that was easy to do:
private function varietyResult(e:ResultEvent):void {
varietyXML = XMLList(e.result.variety);
}
So, for everyone who likes to see the whole picture, like me, here’s the entire MXML code:
import mx.rpc.events.ResultEvent;
[Bindable] private var varietyXML:XMLList;
private function init():void {
varietyService.send();
}
private function varietyResult(e:ResultEvent):void {
varietyXML = XMLList(e.result.variety);
}
]]>

