I have the following XML being returned to my Flex application. How can parse
it so that it displays in a DataGrid?

I was able to get the XML to display in a textarea by using the following
code:

<mx:TextArea id="myTextArea"
text="{ws.getContacts.lastResult.toXMLString()}" width="100%" height="253" 
fontSize="12"/>

<getContactsResponse xmlns="http://simpaq.com/service";
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <getContactsReturn>
    <ns1:contactId xmlns:ns1="http://dto.simpaq.com";>1111</ns1:contactId>
    <ns2:emailAddress
xmlns:ns2="http://dto.simpaq.com";>[EMAIL PROTECTED]</ns2:emailAddress>
    <ns3:firstName xmlns:ns3="http://dto.simpaq.com";>Freddy</ns3:firstName>
    <ns4:lastName xmlns:ns4="http://dto.simpaq.com";>Colmbs</ns4:lastName>
    <ns5:phoneNumber
xmlns:ns5="http://dto.simpaq.com";>555-897-9855</ns5:phoneNumber>
  </getContactsReturn>
  <getContactsReturn>
    <ns6:contactId xmlns:ns6="http://dto.simpaq.com";>2222</ns6:contactId>
    <ns7:emailAddress
xmlns:ns7="http://dto.simpaq.com";>[EMAIL PROTECTED]</ns7:emailAddress>
    <ns8:firstName xmlns:ns8="http://dto.simpaq.com";>John</ns8:firstName>
    <ns9:lastName xmlns:ns9="http://dto.simpaq.com";>Doe</ns9:lastName>
    <ns10:phoneNumber
xmlns:ns10="http://dto.simpaq.com";>555-611-0081</ns10:phoneNumber>
  </getContactsReturn>
  <getContactsReturn>
    <ns11:contactId xmlns:ns11="http://dto.simpaq.com";>3333</ns11:contactId>
    <ns12:emailAddress
xmlns:ns12="http://dto.simpaq.com";>[EMAIL PROTECTED]</ns12:emailAddress>
    <ns13:firstName xmlns:ns13="http://dto.simpaq.com";>Mary</ns13:firstName>
    <ns14:lastName xmlns:ns14="http://dto.simpaq.com";>Jane</ns14:lastName>
    <ns15:phoneNumber
xmlns:ns15="http://dto.simpaq.com";>555-209-4389</ns15:phoneNumber>
  </getContactsReturn>
  <getContactsReturn>
    <ns16:contactId xmlns:ns16="http://dto.simpaq.com";>4444</ns16:contactId>
    <ns17:emailAddress
xmlns:ns17="http://dto.simpaq.com";>[EMAIL PROTECTED]</ns17:emailAddress>
    <ns18:firstName xmlns:ns18="http://dto.simpaq.com";>Cow</ns18:firstName>
    <ns19:lastName xmlns:ns19="http://dto.simpaq.com";>Boy</ns19:lastName>
    <ns20:phoneNumber
xmlns:ns20="http://dto.simpaq.com";>555-298-9455</ns20:phoneNumber>
  </getContactsReturn>
</getContactsResponse>


I tried the following to get it to display in a DataGrid but it didn't work.

<mx:DataGrid id="list"
dataProvider="{ws.getContacts.lastResult.getContactsReturn}" width="100%"
height="100%" >
        <mx:columns>
                <mx:DataGridColumn dataField="contactId" headerText="Contact 
ID" />
                <mx:DataGridColumn dataField="firstName" headerText="First 
Name" />
                <mx:DataGridColumn dataField="lastName" headerText="Last Name" 
/>
                <mx:DataGridColumn dataField="phoneNumber" headerText="Phone 
Number" />
                <mx:DataGridColumn dataField="emailAddress" headerText="Email 
Address" />                               
        </mx:columns>           
</mx:DataGrid>


Any help will be greatly appreciated. 

Thanks.

Gabsaga
-- 
View this message in context: 
http://www.nabble.com/Display-XML-in-DataGrid-tp18517227p18517227.html
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to