XML in Flash Trouble

I’m trying to make a fighting game where character info is loaded from an XML file (just 'cause), and the code doesn’t seem to work.

This is the XML:






</P>



</P><STRENGTH>players>
 player1>
  strength>10/strength>
  health>10/health>
  defence>10/defence>
  speed>2/speed>
  name>Steve/name>
  weapon>Sword/weapon>
 /player1>
 player2>
  strength>10/strength>
  health>10/health>
  defence>10/defence>
  speed>2/speed>
  name>Jo/name>
  weapon>Laser/weapon>
 /player2>
/players>
</WEAPON>
</PLAYER2>
</PLAYERS>

*NOTE: all the <'s were purposfully eliminated because they cause everything between the <>'s to dissapear and I don’t know how to stop that

If the actionscript in the first frame is this:


charInfo = new XML();
charInfo.ignoreWhite = true;
charInfo.load("playerInfo.xml");
charInfo.onLoad = function(success){
if(success){
_root.strength1 = charInfo.firstChild.firstChild.childNodes[0].firstChild.nodeValue;
trace(_root.strength1);
_root.health1 = charInfo.firstChild.firstChild.childNodes[1].firstChild.nodeValue;
_root.defence1 = charInfo.firstChild.firstChild.childNodes[2].firstChild.nodeValue;
_root.speed1 = charInfo.firstChild.firstChild.childNodes[3].firstChild.nodeValue;
_root.name1 = charInfo.firstChild.firstChild.childNodes[4].firstChild.nodeValue;
_root.weapon1 = charInfo.firstChild.firstChild.childNodes[5].firstChild.nodeValue;
_root.strength2 = charInfo.firstChild.childNodes[1].childNodes[0].firstChild.nodeValue;
_root.health2 = charInfo.firstChild.childNodes[1].childNodes[1].firstChild.nodeValue;
_root.defence2 = charInfo.firstChild.childNodes[1].childNodes[2].firstChild.nodeValue;
_root.speed2 = charInfo.firstChild.childNodes[1].childNodes[3].firstChild.nodeValue;
_root.name2 = charInfo.firstChild.childNodes[1].childNodes[4].firstChild.nodeValue;
_root.weapon2 = charInfo.firstChild.childNodes[1].childNodes[5].firstChild.nodeValue;
}
}

it will trace “10”(see the “trace(_root.strength1)”?)

But when it’s like this:


charInfo = new XML();
charInfo.ignoreWhite = true;
charInfo.load("playerInfo.xml");
charInfo.onLoad = function(success){
if(success){
_root.strength1 = charInfo.firstChild.firstChild.childNodes[0].firstChild.nodeValue;
_root.health1 = charInfo.firstChild.firstChild.childNodes[1].firstChild.nodeValue;
_root.defence1 = charInfo.firstChild.firstChild.childNodes[2].firstChild.nodeValue;
_root.speed1 = charInfo.firstChild.firstChild.childNodes[3].firstChild.nodeValue;
_root.name1 = charInfo.firstChild.firstChild.childNodes[4].firstChild.nodeValue;
_root.weapon1 = charInfo.firstChild.firstChild.childNodes[5].firstChild.nodeValue;
_root.strength2 = charInfo.firstChild.childNodes[1].childNodes[0].firstChild.nodeValue;
_root.health2 = charInfo.firstChild.childNodes[1].childNodes[1].firstChild.nodeValue;
_root.defence2 = charInfo.firstChild.childNodes[1].childNodes[2].firstChild.nodeValue;
_root.speed2 = charInfo.firstChild.childNodes[1].childNodes[3].firstChild.nodeValue;
_root.name2 = charInfo.firstChild.childNodes[1].childNodes[4].firstChild.nodeValue;
_root.weapon2 = charInfo.firstChild.childNodes[1].childNodes[5].firstChild.nodeValue;
}
}
trace(_root.strength1);

it traces “undefined”

why does it do this?!