1 Reply Latest reply on Jan 28, 2008 3:12 PM by dazweeja

    xml binding to datagrid

    josh_aries Level 1
      Hi,
      I am trying to bind an xmlfile to the datagrid. I have a file name xxxx.xml in a folder called assets in the application. I am using xmlListCollection and trying to bind it to the datagrid. The code is
      <mx:XML id="Sample" source="{assets/xxxx.xml}" />
      <mx:XMLListCollection id="SampleXML" source="{Sample.SampleNode}" />

      I get the following error

      Data binding expressions not supported with attributes processed at compile time.


        • 1. Re: xml binding to datagrid
          dazweeja
          I think what this error is saying is that the XMLListCollection can't be created because the compiler doesn't know the structure of the XML at compile time (because it hasn't finished loading the XML file). You'll probably have to listen for an event and then create the XMLListCollection, and the datagrid too if you wanted. I think the 'load' event is what you need, eg. (this is untested!)

          <mx:XML id="Sample" source="{assets/xxxx.xml}" load="createXMLLC()" />

          <mx:XMLListCollection id="SampleXML" />

          <mx:Script>
          <![CDATA[

          private function createXMLLC():void
          {
          SampleXML = new XMLListCollection(Sample.SampleNode);
          }
          ]]>
          </mx:Script>