2 Replies Latest reply on Sep 1, 2009 8:58 AM by sirk214

    reading an xml file in actionscript using flex3

    zdevu

      plzz tell me how to read an xml file in actionscript using flex3.......

        • 2. Re: reading an xml file in actionscript using flex3
          sirk214

          One possible option to parse an xml-file to a flex XML object:

           

          public function parseConXML(source:String):void
                      {       
                          xmlLoader = new URLLoader();
                          xmlLoader.load(new URLRequest(source));
                         
                            // Eventlistener: if URL loaded --> onLoadComplete function
                            xmlLoader.addEventListener(Event.COMPLETE, xmlLoadComplete);
                     
                      }
                         
                      public function xmlLoadComplete(evt:Event):void{               
                          var xml:XML = new XML();
                                         
                           // ignore comments in XML-File
                          XML.ignoreComments = true;  
                        
                             //ignore whitespaces in XML-File
                           XML.ignoreWhitespace = true;
                     
                          // XML-Objekt erstellen
                          xml = new XML(evt.target.data);

                         //AFTERWARDS use your xml as your wish

                      }