2 Replies Latest reply on Feb 28, 2010 2:09 PM by j.c.cartwright

    use of XMLList w/ ResultEvent


      Hello All,


      I'm trying to understand the tutorial presented at http://learn.adobe.com/wiki/display/Flex/2b.+Code+Files.  The callback function looks like:


      public function handleXML(event:ResultEvent):void {  
         shippingInfo = event.result.option as XMLList; 



      and the XML being returned is:


      <option><service>Next Day</service><price>0</price></option>
      <option><service>Two Day Air</service><price>0</price></option>
      <option><service>Saver Ground</service><price>0</price></option>

      I assume that the "option" in "event.result.option" means to create a list of all the <option> elements at any depth in the XML string.  However, if I nest the above XML in an additional parent element, it does not parse correctly.   Can someone please clarify for me how the XMLList is being constructed here?  Thanks!  --john

        • 1. Re: use of XMLList w/ ResultEvent
          rickcr Level 1

          I'm still pretty green, but I believe the first node is always assumed as part of your XMLList (in the intial case it was 'options'.) So if you are saying your xml has <options> nested in something else (eg  <myStuff><options><option.... /> ) then you probably would just need..


          shippingInfo = event.result.options.option as XMLList;


          or even...


          shippingInfo = event.result..option as XMLList; //note the two dots


          Being new, I could be wrong though and have not tested the above.

          • 2. Re: use of XMLList w/ ResultEvent
            j.c.cartwright Level 1

            Thanks,  this seems to be what I was looking for.  Didn't anticipate that the root node would be ignored.  Both of your suggestions work but the:


            shippingInfo = event.result..option as XMLList;


            seems best as it doesn't appear to be sensitive to the depth at which the option elements are nested.


            Thanks again for your help!