Problem with feeding variables with loaded XML
If there’s anyone out there who could help that would be great, i’m using mx2004.
I’m trying with not much luck to put the appropriate nodes into variables, trying to find a quicker and better way than below.
urlXML = new XML();
urlXML.onLoad = populateQuestions;
status = “Loading DATA…”;
urlXML.load(“ppcontent.xml”);
// Function : populateQuestions
// Purpose : Takes XML data and populates questions variables
function populateQuestions() {
if(loaded == total){
gotoAndStop(“done”);
}
sections = new Array();
sections = this.childNodes[0].nextSibling.childNodes;
for (x=0; x<=sections.length; ++x) {
if (sections[x].nodeName == “SECTION”) {// make sure we are dealing with a SECTION tag
// this is the code I am trying to get to work…
// the point is to get the below line to feed all the variables.
this.ref[“section”+x+“Name”+x] = sections[x].attributes.NAME;
//eval(“section”+x+“Name”+x) = sections[x].attributes.NAME;
// rather than having to do these below lines over and........
section0Name0 = sections[x].attributes.NAME;// all working
section0Nav0 = sections[x].attributes.NAV;
section0Id0 = sections[x].attributes.ID;
section0Comment0 = sections[x].childNodes[1].childNodes[0];
section0Image0 = sections[x].childNodes[1].nextSibling.nextSibling
subSections = sections[x].childNodes[4].nextSibling.childNodes//.childNodes
for (y=0; y<=subSections.length; ++y) {
if (subSections[y].nodeName == "SUB_SECTION") {//if we are deailing with a subSections tag
subSections0Name0 = subSections[y].attributes.NAME;// all working
subSections0Subnav0 = subSections[y].attributes.SUB_NAV;
subSections0Subid0 = subSections[y].attributes.SUB_ID;
subSections0Comment0 = subSections[y].childNodes[1].childNodes[0];
subSections0Image0 = subSections[y].childNodes[1].nextSibling.nextSibling
}
}
}
}
}
if u can help, much appreciated