Loading data from XML + help with for loop

Hi I’m creating a flash flip book for a 16th century text which is in Latin.

Before I get too into this let me break down relevant functions etc

btn_english = overlay button
txt_enNotes = dynamic text field
mc_enTrans = overlay (only a black box in a movieclip)
notes.xml = XML file
XMLData = XML instance
page = current page number
enTransFlip() = function for the overlay button

I have a button which brings up a semi transparent overlay and a dynamic text field.
Into this text field I need to put notes/translations etc which are in a .xml file.

e.g. XML

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<book>
	<page no="1">
			<note>1 TEST1</note>
			<note>1 TEST2</note>
			<note>1 TEST3</note>
	</page>
	<page no="2">
			<note>2 TEST1</note>
			<note>2 TEST2</note>
			<note>2 TEST3</note>
	</page>
	<page no="3">
			<note>3 TEST1</note>
			<note>3 TEST2</note>
			<note>3 TEST3</note>
	</page>
</book>

I have this xml file loaded in using the following:

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        note = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            note[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
			//trace(xmlNode.firstChild.firstChild.firstChild.nodeValue);
        }
        trace("XML Loaded!");
    } else {
        trace("XML file NOT loaded!");
    }
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load ("notes.xml");

This works fine, and when I press my overlay button it calls the following:

function enTransSwap()
{
	mc_enTrans._visible = !mc_enTrans._visible;
	txt_enNotes._visible = !txt_enNotes._visible;
	txt_enNotes.text = xmlNode.firstChild.firstChild.firstChild.nodeValue;
}

Brilliant, this brings up “1 TEST1” in my dynamic text field.

What I need to do now is get the ‘xmlNode.firstChild.firstChild.firstChild.nodeValue;’ to say "xmlNode.firstChild.<page>.note[i].nodeValue;.

Obviously with some sort of for loop to run through the ‘note’ nodes and increment the note[i] value.

I don’t know where to start with this bit so if anyone could lend a hand I’d be really grateful.

Thanks

:slight_smile: