1 Reply Latest reply on Jun 26, 2007 7:27 PM by ntsiii

    Accessing attributes in dataGrid

    benhoug Level 1
      Hi,

      I'm trying to iterate through a team of players which, once I've loaded my file into XMLfile:XML, I can do like this;
      XMLHomeTeam = XMLFile.Team.(@homeOrAway="Home").Players.Player;

      I can then trace it like this
      trace (XMLHomeTeam = XMLFile.Team.(@homeOrAway="Home").Players.Player);

      which gives;
      <Player id="20000" shirtNumber="1" position="Goal Keeper" substitute="No">
      <Name firstName="Shay" initials="S" lastName="Given"/>
      </Player>
      etc...

      However when I try to assign it in a DataGrid like this;

      <mx:DataGrid id="HomeTeamGrid" dataProvider="{XMLHomeTeam}">
      <mx:columns>
      <mx:DataGridColumn dataField="Name.@firstName" headerText="First name" />
      <mx:DataGridColumn dataField="Name.@lastName" headerText="Last name" />
      <mx:DataGridColumn dataField="@position" headerText="Position" />
      <mx:DataGridColumn dataField="@substitute" headerText="Sub" />
      </mx:columns>
      </mx:DataGrid>

      I only see the "direct" attributes of the node, @position and @substitute, but not the firstName and lastName, which are in the "Name" child node.

      Hopefully this is an easy one! Anyone...?