XML Parsing


1.xml

<employeeDB>
<tblEmpDetails>
<empdetails>
<empId>1001</empId>
<empname>J</empname>
<empsalary>10000</empsalary>
<empgender>Male</empgender>
</empdetails>
<empdetails>
<empId>1002</empId>
<empname>Ja</empname>
<empsalary>20000</empsalary>
<empgender>Male</empgender>
</empdetails>
<empdetails>
<empId>1003</empId>
<empname>Jag</empname>
<empsalary>30000</empsalary>
<empgender>Male</empgender>
</empdetails>
<empdetails>
<empId>1004</empId>
<empname>Jaga</empname>
<empsalary>60000</empsalary>
<empgender>FeMale</empgender>
</empdetails>
<empdetails>
<empId>1004</empId>
<empname>Jagan</empname>
<empsalary>65000</empsalary>
<empgender>FeMale</empgender>
</empdetails>
</tblEmpDetails>
</employeeDB>

DisplayinGrid.MXML

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”vertical” initialize=”srv.send()” >
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.Label;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
var arremp:ArrayCollection=new ArrayCollection;
private function rsevent(e:ResultEvent)
{
arremp=e.result.employeeDB.tblEmpDetails.empdetails;
dg.dataProvider=arremp;
dg.rowCount=arremp.length;
}
private function flevent(e:FaultEvent)
{
Alert.show(‘fault ‘+e.fault.toString());
}
private function rep()
{
lb.text=dg.selectedItem.empname;
}
]]>
</mx:Script>
<mx:HTTPService id=”srv” url=”1.xml” result=”rsevent(event)”  fault=”flevent(event)”/>
<mx:DataGrid id=”dg”  x=”239″ y=”29″ change=”rep()” />
<mx:Label id=”lb” width=”500″  x=”258″ y=”377″/>
</mx:Application>

Advertisements

~ by mjcprasad2000 on April 28, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

 
%d bloggers like this: