[Help] New person cant read node ...
Hey everyone
Well Im new to XML and Im trying to get a highscore system to work for a game Ive created. Im not asking you to make one for me, I just need a little help with this problem Im having
For the sake of tutorial and learning, Ill just break it down to the specific problem that Im facing
1) I have an XML file called 'highscore.xml' with the following in it:
<?xml version="1.0"?>
<highscore>
<player1>Matthew</player1>
<score1>100</score1>
</highscore>
2) I then load the xml into flash using:
my_xml.load("C:\\Inetpub\\wwwroot\\games\\highscor e.xml");
3) I attempt to grab the first node 'player' to simply display it in a trace (for now) :
highElement = my_xml.firstChild;
playerElement = highElement.firstChild;
playerText = playerElement.nodeValue;
trace(playerText);
As you can see Ive made variables for the different parts of the xml all the way down to the text inside the element 'player'. When I run the program and click the button in which the code is in, the trace(playerText); returns an undefined value
Here is my whole code for the button :
on (release) {
my_xml = new XML();
myLoadxml = new XML();
my_xml.load("C:\\Inetpub\\wwwroot\\games\\highscor e.xml");
my_xml.onLoad = function(success) {
if (success) {
highElement = my_xml.firstChild;
playerElement = highElement.firstChild;
playerText = playerElement.nodeValue;
trace(playerText);
my_xml.contentType = "text/xml";
my_xml.xmlDecl = "<?xml version=\"1.0\" ?>";
my_xml.sendAndLoad("http://localhost/games/test.asp", myLoadxml);
trace(my_xml.firstChild.nodeValue);
} else {
}
};
}
If someone code please help me out with this XML, it would be greatly appreciated