1 Reply Latest reply on May 19, 2007 1:25 PM by firespade

    Beware malformed XML!

    snafu7x7
      It seems that Flex just swallows any exceptions when you try to load a malformed or invalid xml document as follows. I had a document where I forgot to close my tags at the end and despite spending a day in the debugger stepping thru the code it never threw an exception and I was unable to catch anything with try-catch. The behavior I saw was that the Load function below would execute completely but its event handler onLoad below would never fire.

      public static function Load():void{
      var url:String = " http://someurl/malformed.xml";
      var service:HTTPService = new HTTPService();
      service.resultFormat = "e4x";
      service.url = url;
      service.addEventListener(ResultEvent.RESULT, onLoad);
      service.send();
      }

      private static function onLoad(event:ResultEvent):void{
      var myxml:XMLListCollection = new XMLListCollection(event.result.*);
      }
        • 1. Re: Beware malformed XML!
          firespade
          Yeah, Flex is pretty adamant about "legal" XML structure. I too have experimented with the same thing. Outputting data from MySQL via PHP proxy into Flex. I didn't succeed many times, but once I realized that a mismatched tag could cause the onLoad event to fail, I started to run my XML through a validator before sending it out to the proxy bridge.