3 Replies Latest reply on Aug 27, 2008 1:10 AM by eiral

    xml config parsing problem

    eiral
      hi,

      i've got a problem when i try to parse the xml config file in the application directory.
      i'm trying to make a class to update my application if necessary. for that i parse the config file to see which version the user have. Then i parse an other xml file on a web server and if the version differ, i update the user application with the new one.

      the problem is : when i parse the user config xml, i've got nothing ! but the xml file is well parsed...
      here some part of my code :


      public function checkUpdate():void
      {
      trace("checkupdate()");
      var loader:URLLoader = new URLLoader();
      loader.addEventListener(Event.COMPLETE, readVersion);
      loader.addEventListener(IOErrorEvent.IO_ERROR, localError);

      var request:URLRequest = new URLRequest(File.applicationDirectory.resolvePath(xmlFile).url);
      loader.dataFormat = URLLoaderDataFormat.TEXT
      loader.load(request);
      }

      private function readVersion(event:Event):void
      {
      trace("readVersion()");
      var localload:URLLoader = URLLoader(event.target);
      XML.ignoreComments = true;

      parser = XML(localload.data);
      trace("local version: " + parser.version);
      trace(parser.toXMLString());
      ...
      }

      private var parser:XML;
      private var xmlFile:String;


      and here is the result in the console :

      checkupdate()
      readVersion()
      local version:

      <application xmlns=" http://ns.adobe.com/air/application/1.0">
      <id>checkversion</id>
      <filename>checkversion</filename>
      <name>checkversion</name>
      <version>1</version>
      <initialWindow>
      <content>checkversion.swf</content>
      <width>640</width>
      <height>480</height>
      </initialWindow>
      </application>

      we can see that the file is well parsed, but i've got nothing inside parser.version :(

      the most strange is when i change the xml file it works !
      same code, different xml file (in the same directory) :

      readVersion()
      local version: 1

      <pviLocalVersion>
      <version>1</version>
      </pviLocalVersion>


      here i got the version ..


      please help !