1 Reply Latest reply on Oct 20, 2006 11:01 AM by M40

    Populate ComboBox with XML data

    M40 Level 1
      I'd like to populate a ComboBox control with the data from a simple xml file like the one below. It's probably quite newbie question but I couldn't find the answer searching in this forum and the documentation so far.


      I'd highly appreciate if someone tell me how to make the ComboBox get data from XML file. Thanks!
        • 1. Re: Populate ComboBox with XML data?
          M40 Level 1
          I found a way to do it. Below is the code I use to populate a ComboBox control with dynamically loaded XML data (the XML content is in the first post).
          I'm sorry I opened a topic for such a basic question. Anyway I hope the thread is useful for someone. If you think there is sth wrong with the code below, please post a reply.

          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="parseXML();">


          public var myXML:XML
          public var myLoader:URLLoader

          function parseXML():void{
          myXML = new XML();
          var XML_URL:String = "content.xml";
          var myXMLURL:URLRequest = new URLRequest(XML_URL);
          myLoader = new URLLoader(myXMLURL);
          myLoader.addEventListener("complete", xmlLoaded);

          function xmlLoaded(evtObj:Event):void {
          myXML = XML(myLoader.data);
          combo.dataProvider = myXML.children();


          <mx:Panel title="ComboBox Example" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
          <mx:ComboBox id="combo" />