0 Replies Latest reply on Nov 11, 2009 10:19 PM by RajaFlex

    XML appendChild() behaves strange.

    RajaFlex

      HI,

       

      I have a strange problem. I am reading an XML (directReport) through HTTPService. For the first time when the application initializes, it goes thru the if loop and everything works fine as expected(if I Alert, it shows me the whole appended XML), but for the 2nd time, same HTTPService request is called and it goes thru the else part ( here the directReportChildXML appends to the contractXML/colleagueXML ) , but when I Alert, it shows only the last node appended. Can anyone please help?

       

      Thanks in advance.

       

       

      public function directReportsResultHandler( event:ResultEvent ) : void {
              try{
                  directReport = event.result as XML;
                  //Alert.show(""+directReport);
                 
                  var rootNode:String = "<"+directReport.name()+">"+"</"+directReport.name()+">"
                  colleagueXML = new XML(rootNode);
                  contractorXML = new XML(rootNode);
                 
                  var childXmlList:XMLList = new XMLList();
                  childXmlList = directReport.child("*");

                  if(baseXML.child("*").length() == 0){
                      baseXML = directReport;
                      for each(var initialDirectReportChildXML:XML in childXmlList){
                          if(initialDirectReportChildXML.@TYPE == "D"){
                              colleagueXML.appendChild(initialDirectReportChildXML);
                          }else{
                              contractorXML.appendChild(initialDirectReportChildXML);
                          }
                      }

                     Alert.show(""+contractorXML);
                  }else{
                      for each(var directReportChildXML:XML in childXmlList){
                          if(directReportChildXML.@TYPE == "D"){
                              colleagueXML.appendChild(directReportChildXML);
                          }else{
                              contractorXML.appendChild(directReportChildXML);
                          }
                          baseXML.appendChild(directReportChildXML);
                      }

                     Alert.show(""+contractorXML);
                  }
                  drRepeater.dataProvider = colleagueXML.FIELDS;

               
              }
              catch(e:Error){
                  //
              }
          }

       

      directReport.xml

      *******************

       

      Base<data POSITION="10083037">
        <FIELDS TYPE="D" LEVEL="2" POSITION="10061755" REPORTSTO="10083037" COUNT="1">
          <empId>1453501</empId>
          <empName>Josefin Crawford</empName>
          <offPhone>858/881-54</offPhone>
          <mobilePhone>434/164763</mobilePhone>
          <eMail>test@test.com</eMail>
          <designation>Global HRBT Manager, Asia Pac.</designation>
          <dept>CIT - Enterprise Applications</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="00269324" REPORTSTO="10083037" COUNT="0">
          <empId>1196970</empId>
          <empName>Kristen Zimmerman</empName>
          <offPhone>53218-4901</offPhone>
          <mobilePhone>878935</mobilePhone>
          <eMail>test@test.com</eMail>
          <designation>Global HRBT Manager, EMEA</designation>
          <dept>Global HR Business Technology</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="00177047" REPORTSTO="10083037" COUNT="0">
          <empId>1196604</empId>
          <empName>Dirk Zanirato</empName>
          <offPhone>785/5-4203</offPhone>
          <mobilePhone/>
          <eMail>test@test.com</eMail>
          <designation>Global Manager HRBT LA/Canada</designation>
          <dept>Corporate HR - Brazil</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="10156533" REPORTSTO="10083037" COUNT="0">
          <empId>1196112</empId>
          <empName>Christopher Zapata</empName>
          <offPhone>834/14-859</offPhone>
          <mobilePhone>99205-9275</mobilePhone>
          <eMail>test@test.com</eMail>
          <designation>HRIT Client Partner Manager</designation>
          <dept>CIT – Enterprise Applications</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="10061271" REPORTSTO="10083037" COUNT="0">
          <empId>1195476</empId>
          <empName>Travis Zigler</empName>
          <offPhone>205/2-5831</offPhone>
          <mobilePhone>106/924-288</mobilePhone>
          <eMail>test@test.com</eMail>
          <designation>Sr Mgr, Global Country Support</designation>
          <dept>Global HR Business Technology</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="10161825" REPORTSTO="10083037" COUNT="11">
          <empId>004608</empId>
          <empName>Daphne Hammer</empName>
          <offPhone>+1.146.277.727</offPhone>
          <mobilePhone>+1.264.208.87</mobilePhone>
          <eMail>test@test.com</eMail>
          <designation>Director</designation>
          <dept>HR IT</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="10161835" REPORTSTO="10083037" COUNT="0">
          <empId/>
          <empName>Open Position</empName>
          <offPhone/>
          <mobilePhone/>
          <eMail>test@test.com</eMail>
          <designation>Manager</designation>
          <dept>HR IT</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="10161828" REPORTSTO="10083037" COUNT="7">
          <empId/>
          <empName>Open Position</empName>
          <offPhone/>
          <mobilePhone/>
          <eMail>test@test.com</eMail>
          <designation>Director</designation>
          <dept>HR IT</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="00020547" REPORTSTO="10083037" COUNT="0">
          <empId/>
          <empName>Open Position</empName>
          <offPhone/>
          <mobilePhone/>
          <eMail>test@test.com</eMail>
          <designation>Manager</designation>
          <dept>HR IT</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="00242088" REPORTSTO="10083037" COUNT="2">
          <empId/>
          <empName>Open Position</empName>
          <offPhone/>
          <mobilePhone/>
          <eMail>test@test.com</eMail>
          <designation>Sr Manager</designation>
          <dept>HR IT</dept>
        </FIELDS>
        <FIELDS TYPE="D" LEVEL="2" POSITION="10161862" REPORTSTO="10083037" COUNT="0">
          <empId/>
          <empName>Open Position</empName>
          <offPhone/>
          <mobilePhone/>
          <eMail>test@test.com</eMail>
          <designation>Manager</designation>
          <dept>HR IT</dept>
        </FIELDS>
        <FIELDS TYPE="C" LEVEL="0" POSITION="" REPORTSTO="10083037" COUNT="0">
          <empId>1390364</empId>
          <empName>Alexey Colby</empName>
          <offPhone>314-274-321</offPhone>
          <mobilePhone>314-274-03</mobilePhone>
          <eMail>test@test.com</eMail>
          <designation>Contractor</designation>
          <dept>New York, NY</dept>
        </FIELDS>
        <FIELDS TYPE="C" LEVEL="0" POSITION="" REPORTSTO="10083037" COUNT="0">
          <empId>1391329</empId>
          <empName>Reed Crawley</empName>
          <offPhone>314-274-3021</offPhone>
          <mobilePhone>314-274-03</mobilePhone>
          <eMail>test@test.com</eMail>
          <designation>Contractor</designation>
          <dept>New York, NY</dept>
        </FIELDS>
      </data>

       

      - RajaFlex