After a little digging and a couple cups of coffee, I managed
to pull some data extracting from xml into a datagrid. I can access
attributes, node values, etc...
One thing I did notice, is that you have to refresh the
application if you have dynamic data constantly being updated. So
here is some code to help some of you out:
First some sample XML (index.xml):
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<records>
<active name="John" id="1234" location="New York">
<job>Architect</job>
<address>111 Salisbury Rd</address>
</active>
<inactive name="Chris" id="5432" location="California">
<job>Web Designer</job>
<address>888 Orchard Rd</address>
</inactive>
</records>
Code with two tabs one name (
Active), other named (
Inactive):
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:local="*" pageTitle="Test App"
creationComplete="srv.send()">
<mx:HTTPService id="srv" url="
http://www.domain.com/index.xml?rand=math.random();"
resultFormat="e4x" useProxy="false" showBusyCursor="true" />
<mx:XMLListCollection id="xActive"
source="{srv.lastResult.active}" />
<mx:XMLListCollection id="xInActive"
source="{srv.lastResult.inactive}" />
<mx:script>
<[[
private function RefreshData():void{
xActive.refresh();
xInActive.refresh();
}
]]>
</mx:Script>
<mx:TabNavigator>
<mx:Canvas label="Active" width="100%" height="100%"
id="canvas1" initialize="RefreshData();">
<mx:DataGrid id="activeData" dataProvider="{xActive}"
selectedIndex="0" editable="true" enabled="true">
<mx:columns>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@name" headerText="Name"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@id" headerText="ID"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@location" headerText="Location"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="job" headerText="Job"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="address" headerText="Address"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:Canvas label="Inactive" width="100%" height="100%"
id="canvas2" initialize="RefreshData();">
<mx:DataGrid id="inactiveData" dataProvider="{xInActive}"
selectedIndex="0" editable="true" enabled="true">
<mx:columns>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@name" headerText="Name"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@id" headerText="ID"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@location" headerText="Location"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="job" headerText="Job"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="address" headerText="Address"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
</mx:TabNavigator>
</mx:Application>