3 Replies Latest reply on May 18, 2009 9:47 AM by flexstone

    Please help me extract this xml

    noppanit Level 1

      <responseResponse xmlns="http://chatter" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <responseReturn>I want this!!!</responseReturn>
      </responseResponse>

       

      I have this xml, it's a result from webservice with e4x format. I want this element  <responseReturn>. I have tried this and it came with nothing.

       

                private function resultService( event:ResultEvent ) :void
                  {

                     Alert.show( event.responseResponse.responseReturn.toString() );


                  }

       

      Thanks a lot

        • 1. Re: Please help me extract this xml
          flexstone Level 1

          try...

          var res = event.result

          trace(res.responseResponse.responseReturn.toString())

          • 2. Re: Please help me extract this xml
            Gregory Lafrance Level 6

            This works, so maybe keep that extra stuff out of the xml:

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
              creationComplete="dataSrvc.send();">
              <mx:Script>
                <![CDATA[
                  import mx.rpc.events.ResultEvent;
                  import mx.collections.XMLListCollection;
                  
                  [Bindable] private var dataXLC:XMLListCollection;
                  
                  private function dataHandler(evt:ResultEvent):void{
                    dataXLC = new XMLListCollection(evt.result.responseReturn as XMLList);
                  }
                ]]>
              </mx:Script>
              <mx:HTTPService id="dataSrvc" result="dataHandler(event)"
                resultFormat="e4x" url="data.xml"/>
              <mx:ComboBox dataProvider="{dataXLC}"/>
            </mx:Application>
            <?xml version="1.0" encoding="utf8"?>
            <responseResponses>
               <responseReturn>I want this!!!</responseReturn>
               <responseReturn>And this!!!</responseReturn>
               <responseReturn>And also this!!!</responseReturn>
            </responseResponse>
            
            • 3. Re: Please help me extract this xml
              flexstone Level 1

              var res = event.result

              var n = res.responseResult.length()

               

               

              for(var i=0;i<n;i++){

                   trace(res.responseResult[i].toString())

              }