1 Reply Latest reply on Oct 7, 2007 7:44 AM by clbeech

    xml wont load

    jagguy99 Level 1
      i can load xml file and display using trace but when displaying the contents in XML variables I get nothing.
      If i hardcode a string with the same XML eg var sXML:String =.... it works.

      var xmlData:XML =new XML();

      var sXML:String ;

      function loadData():Void {
      //var bsuccess:Boolean ;
      trace("dd");
      xmlData.onLoad=function(bsuccess:Boolean):Void {
      if (bsuccess){
      // trace(this.toString());
      sXML=this.toString()
      showData();

      }
      else {
      trace ("failed");
      }
      };

      }


      function showData():Void {
      //trace(sXML); works fine..............

      var xmlVal:XML =new XML();
      xmlVal.parseXML(sXML);
      xmlVal.ignoreWhite =true;
      trace(xmlVal.status);
      //trace(sXML);

      var xRootNode:XMLNode =xmlVal.firstChild ;
      var xnBook:XMLNode =xRootNode.firstChild;

      var aChild:Array =xnBook.childNodes;
      for (var i:Number =0; i<aChild.length; i++) {
      trace(aChild .toString()); //nothing ???????????????????

      }

      }
        • 1. Re: xml wont load
          clbeech Level 3
          Alright, what your doing here is imediately converting the XML to a string, therefore in your second function, it is no longer XML, 'sXML' is a string so you can't perform XML method on it. what you need to do is put the incoming XML elements into an array, then you can call them out independantly.