3 Replies Latest reply on Feb 2, 2007 11:39 AM by Peter Lorent

    Load XML Values into an array

    shaunie123
      Hi,

      I am having problems loading XML values into an array, here is my code:

      var budgetImpactValues:Array = new Array();
      var myXML:XML = new XML();
      myXML.ignoreWhite = true;
      myXML.onLoad = function(success) {
      if (success) {
      importData();
      trace(budgetImpactValues.value.toString());
      } else {
      // error
      }
      };
      myXML.load(mdm.Application.path+"myFile.xml");

      function importData() {
      for (n=0; n<myXML.firstChild.childNodes.length; n++) {
      var value = myXML.firstChild.childNodes[n].firstChild.nodeValue;
      budgetImpactValues[n] = value;
      }
      }

      When I attempt to do a trace on budgetImpactValues, I get undefined, however if I do the trace from within the function the values are there, can anyone see what I am doing wrong here please?

      Thanks for your advice