2 Replies Latest reply on Jan 31, 2007 11:26 AM by jlingwai

    Having issues loading external xml documents

    xyco45
      Okay when I put this code in it works fine...



      var myXML:XML =
      <order>
      <book>
      <title>Dictionary</title>
      </book>
      </order>;

      var childName:String = "book";
      trace(myXML.child(childName).title) // output: Dictionary

      it displays the word "Dictionary" like I want it, but when I try and place that same xml code in a xml file and try and load and read it it doesn't work..




      var myXML:XML = new XML();
      var XML_URL:String = "test.xml";
      var myXMLURL:URLRequest = new URLRequest(XML_URL);
      var myLoader:URLLoader = new URLLoader(myXMLURL);
      myLoader.addEventListener("complete", xmlLoaded);

      function xmlLoaded(evtObj:Event):void
      {
      myXML = XML(myLoader.data);
      trace("Data loaded.");
      }

      var childName:String = "book";
      trace(myXML.child(childName).title) // output: Dictionary

      test.xml code...

      <order>
      <book>
      <title>Dictionary</title>
      </book>
      </order>

      when I try and do it this way the message "data loaded" is outputted meaning the xml doc loaded, but the second trace message doesn't appear.. its just a blank space where it shoudl be outputting "Dictionary"... What am I doing wrong?