Hi there
I am trying to load a master xml file which has a list of all xml files in my project e.g.
<?xml version=“1.0” encoding=“UTF-8”?>
<content>
<xml src = “one.xml”/>
<xml src = “two.xml”/>
</content>
In turn, i then want to create a new xml object for each of these xml files and load the content of each of them.
I have managed to parse the master xml file holding the list of all xml files. And so I am looping around and trying to load each of these.
PROBLEM: For each one in the loop i.e. two files in my case, I am only able to load one of these files i.e. two.xml. I don’t understand! Here’s my ActionScript
function extractInnerXML(){ //function called when master.xml is parsed
//_global.fileList is an array with data from parsing master.xml
//i.e. one.xml, two.xml
for(var i= 0; i<_global.fileList.length; i++){
var fileToLoad = _global.fileList*;
myXML= new XML();
myXML.ignoreWhite = true;
//Load XML file
myXML.load(fileToLoad);
trace("Loading file : "+fileToLoad)
myXML.onLoad = myOnLoad2;
}
}
function myOnLoad2(success){
trace("In myOnLoad2");
if (success) {
trace("success");
firstTag = myXML.firstChild;
trace("firstTag = "+firstTag);
//this trace produces NULL first time round. See output below
}else{
trace("error");
}
}
[color=RoyalBlue]OUTPUT PANEL[/color]
Loading file : one.xml
Loading file : three.xml
In myOnLoad2
success
firstTag = null
In myOnLoad2
success
firstTag = <content><screen><title>Shopping</title><paragraph>A joint production between HBO Films and the BBC</paragraph><paragraph>But when Gina starts challenging </paragraph><paragraph>A timely love story, </paragraph></screen></content>