2 Replies Latest reply on Jan 25, 2009 9:14 AM by ntsiii

    Getting data from multiple XML Files

    miglara
      Could any one please shed some light about the best way to read multiple external xml files through Flex? We haveabout 100 different xml files (of which only few are randomly accessed by the users).
      I tried implementing the following generic function which takes a filename but when debugging it, it seems that the handler never gets call after executing the service.send() line! I will greatly appreciate your help!!!

      public function fetchFileContent(fileName:String):void{ //this method is called upon clicking on a button
      var service:HTTPService = new HTTPService();
      service.url = "filePath/" + fileName ;
      service.useProxy = false;
      service.resultFormat = "e4x";
      service.addEventListener ("result",fileRetrievalHandler)
      service.send();
      }

      public function fileRetrievalHandler(evnt:ResultEvent):void{
      fileContent = evnt.result.feed; //this line never gets executed
      }

        • 1. Re: Getting data from multiple XML Files
          Level 7

          "miglara" <webforumsuser@macromedia.com> wrote in message
          news:glhase$5sr$1@forums.macromedia.com...
          > Could any one please shed some light about the best way to read multiple
          > external xml files through Flex? We haveabout 100 different xml files (of
          > which
          > only few are randomly accessed by the users).
          > I tried implementing the following generic function which takes a
          > filename
          > but when debugging it, it seems that the handler never gets call after
          > executing the service.send() line! I will greatly appreciate your help!!!
          >
          > public function fetchFileContent(fileName:String):void{ //this method is
          > called upon clicking on a button
          > var service:HTTPService = new HTTPService();
          > service.url = "filePath/" + fileName ;
          > service.useProxy = false;
          > service.resultFormat = "e4x";
          > service.addEventListener ("result",fileRetrievalHandler)
          > service.send();
          > }
          >
          > public function fileRetrievalHandler(evnt:ResultEvent):void{
          > fileContent = evnt.result.feed; //this line never gets executed
          > }

          Try adding a fault handler and seeing if that fires. Also, since you're
          using HTTPService instead of URLLoader, be aware that this probably won't
          ever work from your development environment unless you've either changed the
          output directory to go to the server or you've changed some compiler flags
          to allow you to get local and network access at the same time. This is why
          I always use URLLoader to load in XML files at a relative path...it just
          works, without my needing to change anything.


          • 2. Re: Getting data from multiple XML Files
            ntsiii Level 3
            Flex Builder takes care of those data access issues in the development environment.