i am unable to read the data from the xml file to data grid

the flex code in the eclipse
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<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" url="employees.xml"
      result="resultHandler(event)" />

<mx:DataGrid dataProvider="{employeeData}" >
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="First Name" />
</mx:columns>
</mx:DataGrid>
</mx:Application>


and I created the xml file in the src folder the code for the xml is
<?xml version="1.0" encoding="UTF-8"?>
 <employees>
       <employee>
        <name>Colorado Room</name>
        <roomsize>20x20</roomsize>
        <cateringservice>Yes</cateringservice>
        <restroomlocation>Westside near elevator</restroomlocation>
        <capacity>150</capacity>
        <windows>South wall all glass, garden view</windows>
        <wheelchair_accessible>Yes</wheelchair_accessible>
        <description>The Colorado Room is a comfortable room for any type of event. It is a popular room so book now!</description>
        <stars>5</stars>
        <publictelephone_location>Entry level: North wall</publictelephone_location>
       </employee>
      
<employee>
        <name>Mile High Room</name>
        <roomsize>25x30</roomsize>
        <cateringservice>Yes</cateringservice>
        <restroomlocation>Westside near elevator</restroomlocation>
        <capacity>100</capacity>
        <windows>One window, north wall</windows>
        <wheelchair_accessible>Yes</wheelchair_accessible>
        <description>The Colorado Room is a comfortable room for any type of event. It is a popular room so book now!</description>
        <stars>3</stars>
        <publictelephone_location>Entry level: North wall</publictelephone_location>
</employee>

<employee>
        <name>Bronco Room</name>
        <roomsize>15x13</roomsize>
        <cateringservice>No</cateringservice>
        <restroomlocation>Eastside near elevator</restroomlocation>
        <capacity>75</capacity>
        <windows>None</windows>
        <wheelchair_accessible>Yes</wheelchair_accessible>
        <description>The Colorado Room is a comfortable room for any type of event. It is a popular room so book now!</description>
        <stars>4</stars>
        <publictelephone_location>Entry level: North wall</publictelephone_location>
 </employee>
 <employee>
  <name>Greeley Room</name>
  <roomsize>20x20</roomsize>
  <cateringservice>Yes</cateringservice>
  <restroomlocation>Westside near elevator</restroomlocation>
  <capacity>150</capacity>
  <windows>South wall all glass, garden view</windows>
  <wheelchair_accessible>Yes</wheelchair_accessible>
  <description>The Colorado Room is a comfortable room for any type of event. It is a popular room so book now!</description>
  <stars>1</stars>
  <publictelephone_location>Entry level: North wall</publictelephone_location>
</employee>
<employee>
 
  <name>Boulder Room</name>
  <roomsize>40x40</roomsize>
  <cateringservice>Yes</cateringservice>
  <restroomlocation>Westside near elevator</restroomlocation>
  <capacity>350</capacity>
  <windows>None</windows>
  <wheelchair_accessible>Yes</wheelchair_accessible>
  <description>The Colorado Room is a comfortable room for any type of event. It is a popular room so book now!</description>
  <stars>3</stars>
  <publictelephone_location>Entry level: North wall</publictelephone_location>
 </employee>
  </employees>

can any expert can help please
ukdasariAsked:
Who is Participating?
 
zzynxConnect With a Mentor Software engineerCommented:
This works for me.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
      creationComplete="onComplete()">
<mx:Script>
      <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;
            
            private function onComplete():void {
            	dg.dataProvider = xmlData.employee;
            }
      ]]>
</mx:Script>
 
<mx:XML source="assets/Employees.xml" id="xmlData"/>
 
<mx:DataGrid id="dg" >
	<mx:columns>
		<mx:DataGridColumn dataField="name" headerText="First Name" />
	</mx:columns>
</mx:DataGrid>
</mx:Application>

Open in new window

0
 
lexxwernCommented:
You'll need to send the service .. ;-)

try this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="applicationCreationCompleteHandler()">
<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;
            }
            
            private function applicationCreationCompleteHandler():void {
                employeeservice.send();
            }
      ]]>
</mx:Script>
<mx:HTTPService id="employeeservice" url="employees.xml"
      result="resultHandler(event)" />
 
<mx:DataGrid dataProvider="{employeeData}" >
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="First Name" />
</mx:columns>
</mx:DataGrid>
</mx:Application>

Open in new window

0
 
ukdasariAuthor Commented:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
      creationComplete="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" url="employees.xml"
      result="resultHandler(event)" resultFormat="e4x" />

<mx:DataGrid dataProvider="{employeeData}" >
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="First Name" />
</mx:columns>
</mx:DataGrid>

</mx:Application>
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
ukdasariAuthor Commented:
thanx for the reply
this is the new code where i added the send service can you tell me what is the problem is please
0
 
zzynxSoftware engineerCommented:
Or to go short:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
      creationComplete="{dg.dataProvider = xmlData.employee;}">
 
<mx:XML source="assets/Employees.xml" id="xmlData"/>
 
<mx:DataGrid id="dg" >
	<mx:columns>
		<mx:DataGridColumn dataField="name" headerText="First Name" />
	</mx:columns>
</mx:DataGrid>
</mx:Application>

Open in new window

0
 
ukdasariAuthor Commented:
so i dont know what is the problem can anyone can help me please
0
 
ukdasariAuthor Commented:
hello
can anyone help me please i am not able to read the data from the xml sheet to the data grid so can anyone can tell me what is the problem
i am struck with this from one week
0
 
zzynxSoftware engineerCommented:
>> can anyone help me please
I thought I did in my previous comments...
0
 
ukdasariAuthor Commented:
yes i added the send method to the application
even i am getting same error
0
 
zzynxSoftware engineerCommented:
Please look at **MY** (zzynx) comments
0
 
zzynxSoftware engineerCommented:
I repeat:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
      creationComplete="{dg.dataProvider = xmlData.employee;}">
 
<mx:XML source="assets/Employees.xml" id="xmlData"/>
 
<mx:DataGrid id="dg" >
        <mx:columns>
                <mx:DataGridColumn dataField="name" headerText="First Name" />
        </mx:columns>
</mx:DataGrid>
</mx:Application>

Open in new window

0
 
dgofmanCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.