0 Replies Latest reply on Apr 8, 2011 3:38 PM by Clay Borne

    Update XML

    Clay Borne Level 1

      Hello,

      I have some XML

      <?xml version="1.0"?>
      <recData>
           <REFERRAL_LOCATION>8576</REFERRAL_LOCATION>
           <LAST_DATE></LAST_DATE>
           <FIRST_BILLING_DATE></FIRST_BILLING_DATE>
           <ROOM_NUMBER></ROOM_NUMBER>
           <DATE_PK0_2>40987*15712</DATE_PK0_2>
           <mv>
                <DOCTORSMV>
                     <DOCTORS>999</DOCTORS>
                     <DOCTORS_NAME>DO NOT USE</DOCTORS_NAME>
                </DOCTORSMV>
                <DXMV>
                     <DX></DX>
                     <DX_NUMBER></DX_NUMBER>
                </DXMV>
                <TESTSMV>
                      <COLLECTOR>AS</COLLECTOR>
                      <CULTURE_NUMBER></CULTURE_NUMBER>
                      <DATE_DRAWN>06 JAN 2011</DATE_DRAWN>
                      <DATE_RECEIVED>01/06/2011</DATE_RECEIVED>
                      <DESCRIPTION>Lipid Profile</DESCRIPTION>
                      <FILE>CHEM</FILE>
                      <FILE_DEPT>CHEM</FILE_DEPT>
                      <P_ENTRY>CJ</P_ENTRY>
                      <PEND_STATUS>FINISHED</PEND_STATUS>
                </TESTSMV>
           </mv>     
           <mv>
                 <TESTSMV>
                      <COLLECTOR>AS</COLLECTOR>
                      <DATE_DRAWN>06 JAN 2011</DATE_DRAWN>
                      <DATE_RECEIVED>01/06/2011</DATE_RECEIVED>
                      <DESCRIPTION>Hemoglobin & Hematocrit</DESCRIPTION>
                      <FILE>HEM</FILE>
                      <FILE_DEPT>HEM</FILE_DEPT>
                      <P_ENTRY>CJ</P_ENTRY>
                      <PEND_STATUS>FINISHED</PEND_STATUS>
                </TESTSMV>
           </mv>
      </recData>
      

       

      I want to be able to change the x occurance of it.  AS you can see I am attempting to replace the contents of the zero occurance with an item from an Array.

       

      var selectedRow:Array = DX_GRID.selectedItems;
      var mainXML:XML = Application.application.orderEntryWin.recData;
      var count:int = 0;
      for each (var item:XML in mainXML.mv.DXMV.DX){
           trace(item.valueOf());
           if (count == 0){
                if (item.valueOf() == ""){
                     mainXML.mv.DXMV.DX[0] = selectedRow[0].mv.DESCRIPTION;
                }
           }
           count += 1;
      }
      

       

      I'm not sure of the nuances of XML in Flex, so any help is appreciated.  Thanks!