loading xml into separate arrays
The first two records of my XML file are below these are two of about 100.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<coursesSummary>
<courses>
<year>2009</year>
<quarter>1</quarter>
<region>Central Courses</region>
<coursecode>3634500</coursecode>
<coursetitle>Bancassurance(BIP) 2- Selling Skills Course</coursetitle>
<coursesrun>1</coursesrun>
<maxplaces>10</maxplaces>
<numberattended>9</numberattended>
<splitbyregion>no</splitbyregion>
<centralreport>yes</centralreport>
</courses>
<courses>
<year>2009</year>
<quarter>1</quarter>
<region>Central Courses</region>
<coursecode>3634600</coursecode>
<coursetitle>Bancassurance (BIP) 3-Developing your Business</coursetitle>
<coursesrun>1</coursesrun>
<maxplaces>15</maxplaces>
<numberattended>8</numberattended>
<splitbyregion>no</splitbyregion>
<centralreport>yes</centralreport>
</courses>
</coursesSummary>
<------------------------------------------------------------>
I need to be able to make an associative array of the elements within the <courses> tag.
I need to be able to show mix and match the data from the 9 arrays.
I can get the data into a text box but am unable to make the arrays work. In test
I only get one item of data from the first <courses> tag. the array below just displays 2009
<------------------ .fla below -------------------------------->
var myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = loadCourses;
var intervalID:Number = setInterval(checkLoad, 5, myXML);
myXML.load("Book2data.xml");
function loadCourses(success:Boolean):Void {
if (success) {
//trace("data");
} else {
//trace("no data");
}
}
function loadCourses():Void {
cNodes = this.childNodes[0].childNodes[0];
var yearArray:Array = cNodes.childNodes[0].firstChild.nodeValue;
for (i=0; i<yearArray.length; i++) {
yearArray = cNodes.childNodes[0].firstChild.nodeValue;
}
trace(yearArray);
courseText.text = cNodes.childNodes[0].firstChild.nodeValue;//year
/*courseText.text = cNodes.childNodes[1].firstChild.nodeValue;//quarter
courseText.text = cNodes.childNodes[2].firstChild.nodeValue;//region
courseText.text = cNodes.childNodes[3].firstChild.nodeValue;//coursecode
courseText.text = cNodes.childNodes[4].firstChild.nodeValue;//coursetitle
courseText.text = cNodes.childNodes[5].firstChild.nodeValue;//coursesrun
courseText.text = cNodes.childNodes[6].firstChild.nodeValue;//maximunplaces
courseText.text = cNodes.childNodes[7].firstChild.nodeValue;//numberattended
courseText.text = cNodes.childNodes[8].firstChild.nodeValue;//splitbyregion
courseText.text = cNodes.childNodes[9].firstChild.nodeValue;//centralreport
*/
}