3 Replies Latest reply on Oct 21, 2010 4:42 AM by BhaskerChari

    Help parsing XML file

    mikall1979

      Hi All,

      I have some troubles trying to load and parse a simple xml file like this:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <entry>

           <id>1</id>

      </entry>

      <entry>

           <id>2</id>

      </entry>

       


      With this few lines of code:

       

                  var url:URLRequest = new URLRequest("myXML.xml");
                  var xml:XML;
                  var rss:URLLoader = new URLLoader();
                  rss.load(url);
                  rss.addEventListener(Event.COMPLETE, readRss);
                 
                  function readRss(e:Event):void{
                      xml = XML(rss.data);               
                      var ns:Namespace=xml.namespace();
                      txt_field.text=xml..ns::entry[0].ns::id;           
                  }

       

      I get this error: A conflict exists with inherited definition spark.components:Application.url in namespace public.

       

      in: var url:URLRequest = new URLRequest("myXML.xml");

       

      Please help me ...  thank you in advance.

       

      Michele

        • 1. Re: Help parsing XML file
          BhaskerChari Level 4

          Hi Michele,

           

          Try to use different name for your URLRequest object...It seems that there is conflict existing with the inherited url property of the Application and the one you declared so do the following..

           

           

          var _url:URLRequest = new URLRequest("myXML.xml");
          var xml:XML;
          var rss:URLLoader = new URLLoader();
          rss.load(_url);

           

           

          Thanks,

          Bhasker

          • 2. Re: Help parsing XML file
            mikall1979 Level 1

             

             

            Wow.. now I have a lot of errors during compiling!!

             

            I now have this code:

             

                        var _url:URLRequest = new URLRequest("myXML.xml");
                        var xml:XML;
                        var rss:URLLoader = new URLLoader();
                        rss.load(_url); {line 14}
                       rss.addEventListener(Event.COMPLETE, readRss); {line 15}
                                  
                        function readRss(e:Event):void{
                        xml = XML(rss.data);               
                        var ns:Namespace=xml.namespace();
                        txt_field.text=xml..ns::entry[0].ns::id;   {line 22}         
                        }

             

            but I have these errors:

             

            Description    Resource    Path    Location    Type
            1120: Access of undefined property _url.    XML2.mxml    /XML2/src    line 14    Flex Problem
            1120: Access of undefined property readRss.    XML2.mxml    /XML2/src    line 15    Flex Problem
            1120: Access of undefined property rss.    XML2.mxml    /XML2/src    line 14    Flex Problem
            1120: Access of undefined property rss.    XML2.mxml    /XML2/src    line 15    Flex Problem
            1120: Access of undefined property txt_field.    XML2.mxml    /XML2/src    line 22    Flex Problem

             

            Please.. help me!

            • 3. Re: Help parsing XML file
              BhaskerChari Level 4

              Try with other names instead something as urlRequest instead of _url. It looks so weird why these errors are coming...very irrelevant

               

              Thanks,

              Bhasker