views:

17

answers:

1

Here I i'm trying to parsing a XML in like below:

<?xml version="1.0" encoding="utf-8" ?>
<spearkerslist>
    <speakers langid="afb" countryid="SA">200000</speakers>
    <speakers langid="acw" countryid="SA">6000000</speakers>
    <speakers langid="ars" countryid="SA">8000000</speakers>
    <speakers langid="arb" countryid="SA">206000000</speakers>
</spearkerslist>

By this code I'm able to parse parameters langid and countryid, but I'm not able to parse the actual values 200000, 6000000,... into the data grid. Is there a way to access this with out changing the generated XML.

<mx:Script>
[Bindable]
private var languagelist:XML = new XML();
</mx:Script>

<mx:DataGrid dataProvider="{languagelist.speakers}">
    <mx:columns>
        <mx:DataGridColumn id="populationCol" dataField="speakers" headerText="Speakers" />
        <mx:DataGridColumn id="countryID" dataField="@countryid" headerText="Country Id" />
        <mx:DataGridColumn id="LangID" dataField="@langid" headerText="Language Id" />
    </mx:columns>
</mx:DataGrid>
+1  A: 

Try it without dataField:

<mx:DataGridColumn id="populationCol" headerText="Speakers" />

If this doesn't work, use labelFunction

<mx:DataGridColumn id="populationCol" headerText="Speakers" 
     labelFunction="dgLabelFunction"/>

Define it as:

public function dgLabelFunction(item:Object, col:DataGridColumn):String
{
    return item.text().toString();
}
Amarghosh
labelFunction() worked for me!
Saneef