4 Replies Latest reply on Jan 11, 2010 11:44 AM by marcflex01

    Using a datagrid to display XML data




      I'm binding xml to a datagrid but I'm having trouble displaying some of the data.  Here's my example.


      Here's my test data:



      private var test:XML =

        <vm:validationMessages xsi:schemaLocation="http://www.location.com/2.0 http://schemas.com/2.0.0/valMessages.xsd" severity="ERROR" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vm="http://www.location.com/2.0" xmlns:zucc="http://www.location.com/results/1.0">

        <vm:validationMessage severity="ERROR" errorCode="ErrorType1" url="www.loc.com">

          <vm:messageDetail>Text I want to return</vm:messageDetail>





      I've set the default namespace here:


      public static const vm:Namespace = new Namespace("http://www.location.com/2.0");

      default xml namespace = vm;



      And here is the datagrid definition:


      <mx:DataGrid x="10" y="30" width="738.5" height="189" id="dgValidation" dataProvider="{test.validationMessage}">


          <mx:DataGridColumn headerText="Severity" dataField="@severity"/>

          <mx:DataGridColumn headerText="Error Code" dataField="@errorCode"/>

          <mx:DataGridColumn headerText="Url" dataField="@url"/>

          <mx:DataGridColumn headerText="Description" dataField="messageDetail"/>






      The attributes "severity, errorCode, url" are being displayed correctly, however "messageDetail" will not display.  I've tried several different ways of calling it with no luck. Is there a way to do this?