Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am able to retrieve data from a xml file but not able to update the data in a xml file using action script in flex. Also how can i add or delete nodes from a xml file.
Posted

1 solution

HOW do you retrieve the data? which format does it have??

Flex is definitely able to deal with XML. In fact it's a script language that is quite similar to XML - it would be a bit strange if it could not work with XML:

Working with XML - Tutorial[^]

Flex Examples for XML[^]
 
Share this answer
 
Comments
Sachendra Pal 21-Jan-12 6:58am    
<s:application xmlns:fx="http://ns.adobe.com/mxml/2009"
="" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minwidth="955" minheight="600" xmlns:empl="services.empl.*">

<fx:script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;

protected function creationCompleteHandler(event:FlexEvent):void
{
getDataResult.token = empl.getData();

}

protected function retrieve(event:MouseEvent):void
{
var l:int;
l=getDataResult.lastResult.length;

if(int(txtID.text)>l-1)
{
Alert.show("No Record Found!!!!");
}
else
{
txtName.text=getDataResult.lastResult[int(txtID.text)].name;

txtRoll.text=getDataResult.lastResult[int(txtID.text)].roll;

txtCity.text=getDataResult.lastResult[int(txtID.text)].city;
}
}


protected function clear(event:Event):void
{
txtID.text="";
txtName.text="";
txtRoll.text="";
txtCity.text="";
}


protected function update(event:Event):void
{
var l:int;
l=getDataResult.lastResult.length;

if(int(txtID.text)>l-1)
{
Alert.show("No Record Found!!!!");
}
else
{


getDataResult.lastResult[int(txtID.text)].name=txtName.text
Alert.show("Data updated successfully");

//txtRoll.text=getDataResult.lastResult[int(txtID.text)].roll;

//txtCity.text=getDataResult.lastResult[int(txtID.text)].city;
}
}


]]>


<fx:declarations>
<s:callresponder id="getDataResult">
<s:callresponder id="putResult">
<empl:empl id="empl" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showbusycursor="true">
<!-- Place non-visual elements (e.g., services, value objects) here -->

<s:panel x="12" y="15" width="298" height="236" title="XML Data Demo">
<s:label x="10" y="54" text="Name">
<s:label x="10" y="88" text="Roll No.">
<s:label x="10" y="121" text="City">
<s:textinput x="84" y="49" id="txtName" width="198">
<s:textinput x="83" y="82" id="txtRoll" width="199">
<s:textinput x="84" y="114" id="txtCity" width="198">
<s:button x="33" y="162" label="Retrieve"
="" creationcomplete="creationCompleteHandler(event)" click="retrieve(event)">
<s:button x="197" y="162" label="Update" click="update(event)">
<s:button x="117" y="162" label="Clear" click="clear(event)">
<s:label x="10" y="25" text="ID">
<s:textinput x="84" y="18" id="txtID">



I ask user to input id then based on id value it retrieves data.
Above is the code by which i am able to retrieve data from a xml file easily but not able to update data into the xml file. Can u plz suggest me the way.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900