Yes. To use the DataField property, the data must be a first level
property of the dataProvider item, as is the street node.  Firstname,
however is another level deep in the xml.

 

You wil need to use a labelFunction() instead of the dataField.  Check
this out in the docs, and search for it on cflex.net.  Post back if you
still have troubles.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of matmls
Sent: Monday, January 29, 2007 4:37 PM
To: [email protected]
Subject: [flexcoders] Accessing nested xml tag using e4x and httpService

 

Below is a sample of my xml file:

<employee id="2" type="part-time">
<name>
<firstname>Ann</firstname>
<lastname>Jones</lastname>
</name>
<street>52 Cove Court</street>
</employee>

I can return results with httpService :

<mx:HTTPService 
id="srv" 
url="employee.xml" 
resultFormat="e4x"
result="resultHandler(event);"
fault="faultHandler(event);" 
/>

I can then access the values in the street tag, but NOT firstname or
lastname in a datagrid:

<mx:DataGrid dataProvider="{srv.lastResult.employee}">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name.firstname"/>
<mx:DataGridColumn headerText="Street" dataField="street"/>
</mx:columns>
</mx:DataGrid>

Is there a syntax problem with the way I am attempting to access
firstname and lastname? I am able to populate an xml object and
access firstname and lastname with:

myXML.employee.name.lastname

Thanks in advance for any assistance.

 

Reply via email to