4 Replies Latest reply on Oct 7, 2009 7:37 AM by camfieldaj

    XML and e4x

    vertmonkee

      I am having problems parsing XML data with e4x.

       

      My code is

       

          <mx:Script>
              <![CDATA[
                  import mx.rpc.http.mxml.HTTPService;
                  import mx.rpc.events.ResultEvent;
             
                  // The initialisation function
                  protected function init():void {
                      var serviceObj:HTTPService = new HTTPService();
                      serviceObj.resultFormat = "e4x";
                      serviceObj.method = "GET";
                      serviceObj.useProxy = false;
                      serviceObj.addEventListener(ResultEvent.RESULT, processResult);
                      serviceObj.url = 'http://localhost/myScriptURL.php';

                      serviceObj.send();
                  }
                 
                  // The result processing function
                  protected function processResult(event:ResultEvent):void {
                      trace("Result");
                      trace(event.result);
                      // make sure the response is cast as the correct data type
                      var XMLResults:XML = event.result as XML;
                      MyDataGrid.dataProvider = XMLResults.user;
                  }
                 
              ]]>
          </mx:Script>
         
          <mx:DataGrid id="MyDataGrid" />

       

       

      The XML is definetley returned as it appears in my trace statement but the data grid does not get populated.

       

      I've been looking at lots of tutorials and have tried following them but with no luck.

       

      Can anyone point out where I am going wrong?

       

      Thanks for any help