3 Replies Latest reply on Sep 3, 2010 7:17 AM by Fabio Cerioni

    Error during filtering XML Objects

    Fabio Cerioni

      Hello,

       

      we are having problems during the filter process with XML objects.

       

      As we try to search for a term in the following example we obtain the corresponding node:

       

          var xml:XML = <layout>
          <region id="main" left="295" width="458" top="35" height="343">
          </region> 
          <region id="main1" left="295" width="458" top="35" height="343">
              <a></a>
          </region> 
          <region id="main" left="295" width="458" top="35" height="343">
          </region> 
          <region id="main" left="295" width="458" top="35" height="343">
          </region> 
          </layout>;
          
          var xmlList:XMLList = xml.region;
          trace( xmlList.(@id=="main1") ); 
      
      /*
        RESULT ->
                <region id="main1" left="295" width="458" top="35" height="343">
                  <a/>
                </region>
      */
      

       

       

      But as soon as we delete the second level, (<a></a>), we dont obtain any result back.

       

          var xml:XML = <layout>
          <region id="main" left="295" width="458" top="35" height="343">
          </region> 
          <region id="main1" left="295" width="458" top="35" height="343">
          </region> 
          <region id="main" left="295" width="458" top="35" height="343">
          </region> 
          <region id="main" left="295" width="458" top="35" height="343">
          </region> 
          </layout>;
          
          var xmlList:XMLList = xml.region;
          trace( xmlList.(@id=="main1") ); // NO RESULT

       

      Could it be a bug from the SDK 3.2? or is the result correct?

       

      Thanks in advance for your help

        • 1. Re: Error during filtering XML Objects
          VRPDeveloper Level 3

          It is not bug .... but it is just misunderstood .. Let me give ur same example and explain. I have removed <a></a>  and just increased 1 more region with same id as main1

           

          var xml:XML = <layout>
              <region id="main" left="295" width="458" top="35" height="343">
              </region>
              <region id="main1" left="295" width="458" top="35" height="343">
                
              </region>
              <region id="main1" left="295" width="458" top="35" height="343">
              </region>
              <region id="main" left="295" width="458" top="35" height="343">
              </region>
              </layout>;
             
              var xmlList:XMLList = xml.region;
              trace( xmlList.(@id=="main1") );

          /*
            RESULT ->
                    <region id="main1" left="295" width="458" top="35" height="343">
                     </region>
                    <region id="main1" left="295" width="458" top="35" height="343">
                   </region>


          */

           

           

               The region with id=="main1" is just written 1.. I mean record with id as main1 is only one so it is not giving you answer. As soon as you increase region with id as main1 it will start giving you answer. It is not matter of writing

          <a></a>

          but is it just misunderstood. I hope you understood.

          • 2. Re: Error during filtering XML Objects
            rashmin.d

            it is not bug in SDK but some time if u traverse or filtering in XML or XMLList object then sometime it is not able to find deep inside node SO, use the method attributes() or attribute() and use toXMLString() method to print node...

             

             

            may be it will help u...

            • 3. Re: Error during filtering XML Objects
              Fabio Cerioni Level 1

              We have seen that you have to use .toXMLString() to print the output

               

              Thanks all for your help