Problem with arrays from xml

I’m not sure if I’ve incorrectly processed the xml, if I’m just going about accessing the data inside my arrays incorrectly, or if my XML is just plain whack. XML and Arrays are both pretty confusing for me. If anybody can post a suggestion, I’ll really appreciate the help.

This is how the XML is structured:


<file_data>
	<chapter id="1" max="2" url="">
		<sentences>
			<sentence><![CDATA[blahblahblah.]]></sentence>
			<sentence><![CDATA[blahedy blah blah.]]></sentence>
			<sentence><![CDATA[blahblah blah blahblah.]]></sentence>
			<sentence><![CDATA[blahblahblah.]]></sentence>
			<sentence><![CDATA[blahedy blah blah.]]></sentence>
			<sentence><![CDATA[blahblah blah blahblah.]]></sentence>
		</sentences>
	</chapter>
	<chapter id="2" max="1" url="">
		<sentences>
			<sentence><![CDATA[blahblahblah.]]></sentence>
		</sentences>
	</chapter>
(....and so on for 23 chapters)
</file_data>

This is how I’m processing it, after removing the whitespace:


function processXML(theXML){
	nodeNum1 = theXML.firstChild.childNodes.length;	for (var i = 0; i <nodeNum1; i++){
		var currentNode = theXML.firstChild.childNodes*;
		this["p"+i+"Array"] 	= new Array();				this["p"+i+"Array"].push(currentNode.attributes.id);		this["p"+i+"Array"].push(currentNode.attributes.max);		this["p"+i+"Array"].push(currentNode.attributes.url);		
		nodeNum2 = theXML.firstChild.childNodes*.firstChild.childNodes.length;
		for (var ii = 0; ii <nodeNum2; ii++){
			var currentNode2 = theXML.firsthChild.childNodes*.firstChild.childNodes[ii];			this["p"+ii+"Array"] 	= new Array();
this["p"+ii+"Array"].push(currentNode.childNodes[0].firstChild.nodeValue);
		}
			
	}
	this.loadStatus_txt.removeTextField();			play();
}

And this is how I’m referring to it when trying to USE the data:


var currChapter = this["p"+i+"Array"][0];
var currMax = this["p"+i+"Array"][1];  //initialize the max as well (later updated in loadcontent)

Please let me know if you know what i’m doing wrong or have any suggestions.