2 Replies Latest reply on Jun 24, 2007 8:25 AM by Dan McAdam

    Modify and send XML from database

    Dan McAdam Level 1

      i'm populating a datagrid with XML from an HTTPService call but am unclear on how to hold changes to the data in XML format until user pushes a button to call another HTTPService to update the database?

      i've tried various ways to assign the lastResult of the HTTPService call to an XML object and update that... but can't find a way to assign the XML returned from the HTTPService call to the XML object...

      i'm using the new book by Kazoun and Lott "Programming Flex 2"
      thanks in advance
      Salem, Oregon
        • 1. Re: Modify and send XML from database
          chris.huston.t10 Level 3
          Set a result event listener for your HTTPService call and then assign the result in this function to your XML object.


          ActionScript3 code:
          private var xmlVariable:XML;
          private function setResult(evt:ResultEvent):void {
          xmlVariable = XML(evt.result);
          myDataGrid.dataProvider = xmlVariable;

          Depending on your xml returned from your HTTPService call, you might need to modify evt.result to evt.result.root or whatever structure you are using.

          • 2. Modify and send XML from database
            Dan McAdam Level 1
            very cool.... thanks so much
            i modified your example to get it to compile like this:

            import mx.rpc.events.ResultEvent;
            import mx.rpc.events.FaultEvent;
            import mx.controls.Alert;

            private var xmlVariable:XML;
            private function setResult(event:ResultEvent):void {
            xmlVariable = XML(event.result);
            jobFamilies.dataProvider = xmlVariable.job;


            <mx:HTTPService id="jobFam"
            url=" http://mywebserver.com/cea/admin_jobs.php" //not a real url
            useProxy="false" />
            <mx:DataGrid x="144" y="122" width="427" id="jobFamilies" editable="true">
            <mx:DataGridColumn headerText="Fam ID" dataField="jobid"/>
            <mx:DataGridColumn headerText="Survey ID" dataField="surveyid"/>
            <mx:DataGridColumn headerText="Family Name" dataField="familyname"/>
            <mx:Button x="312" y="286" label="Button" click="jobFam.send();"/>

            ******* the returned XML looks like this ********************
            Now i can modify this XML object and return the result back to another HTTPService call... instead of having to to build a new XML structure

            best regards
            Salem, Oregon