Accessing loaded XML information

Ok so now i’m adding XML to my little gallery that ive been working on past couple weeks…

here’s my code:

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("xml.xml");
function loadXML(loaded) {
    if (loaded) {
        trace("XML LOADED");
        xmlNode = this.firstChild;
        title_a = [];
        type_a = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            title_a* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            type_a* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
        }
    } else {
        trace("XML ERROR");
    }
}

function displayInfo() {
    trace(title_a[0]);
}
displayInfo();

now if you notice the function at the bottom displayInfo(){
thats where I want to display my XML, in this case, the first value in the title_a array, but it returns undefined and I cant think of the path I would need…

You are calling displayInfo before the XML has loaded :wink:

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("xml.xml");
function loadXML(loaded) {
 if (loaded) {
  trace("XML LOADED");
  xmlNode = this.firstChild;
  title_a = [];
  type_a = [];
  total = xmlNode.childNodes.length;
  for (i = 0; i < total; i++) {
   title_a* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
   type_a* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
  }
  displayInfo();
 } else {
  trace("XML ERROR");
 }
}
function displayInfo() {
 trace(title_a[0]);
}

Yea fortunately I figured it out soon after i posted here, thanks though :thumb::thumb: