4 Replies Latest reply on Feb 12, 2010 1:01 AM by Sreelash

    Issue with Http Service excercise

    Sreelash Level 1

      Hi,

       

      I am trying to load an xml file and displaying the result in a data grid. Actually i followed the tutorial provided by http service excercise. The foollowing code i used.

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
          layout="absolute"
          initialize="employeeService.send()">
          <mx:Script>
              <![CDATA[
                  import mx.collections.ArrayCollection;
                  import mx.rpc.events.ResultEvent;
                 
                  [Bindable]
                  private var employeeData:ArrayCollection;
                 
                  private function resultHandler(event:ResultEvent):void{
                      employeeData = event.result.employees.employee;
                  }
              ]]>
          </mx:Script>
         
          <mx:HTTPService id="employeeService"
                result="resultHandler(event)"
               url="~/data/employees.xml"/>
              
              
          <mx:DataGrid dataProvider="{employeeData}"     
               width="100%" height="100%"/>
      </mx:Application>

       

       

      The following xml is used with name as employees.xml:

       

      <?xml version="1.0" encoding="utf-8"?>
      <employees>
           <employee>
              <firstname>Sreelash</firstname>
              <lastname>S</lastname>
              <id>sree</id>
              <title>Junior Software Engineer</title>
              <email>sreelash.s@eisplc.com</email>
              <managerid>bfre</managerid>
              <department>Development</department>
              <location>india</location>
              <phone>09995107016</phone>
              <directdial>9995107016</directdial>
              <desklocation>45</desklocation>
              <city>Thiruvananthapuram</city>
              <state>Kerala</state>
              <countrycode>0091</countrycode>
              <postalcode>695024</postalcode>
          </employee>
      </employees>

       

       

      Thanks and regards,

      Sreelash.