Ive got a xml-doc (simply structured, see below for sample) that I load into my flash-app using a loop.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<datapacket>
<row GlobalName="gl_Project_SO_Name" GlobalValue="SpOn2" />
<row GlobalName="gl_BgColor_1" GlobalValue="0xFFFFFF" />
<row GlobalName="gl_BgColor_2" GlobalValue="0xF6E966" />
</datapacket>
However, at one time in the code I want to be able to get just one of those values (gl_Project_SO_Name) from the xml-file. How can this be done most easily?
The code I use to load all the variables into global variables is:
// code: LOAD XML
var s_ProjName_Name = "";
var s_ProjName_Value = 0;
var xml_ProjName = new XML();
xml_ProjName.ignoreWhite = true;
xml_ProjName.onLoad = function(success){
if (success){
for (var row in this.firstChild.childNodes) {
// SET GLOBALS
s_ProjName_Name = this.firstChild.childNodes[row].attributes.GlobalName;
s_ProjName_Value = this.firstChild.childNodes[row].attributes.GlobalValue;
// set: Sätt in rätt värde i rätt global
_global[s_ProjName_Name] = s_ProjName_Value;
}
}
}
xml_ProjName.load("INIT/init.xml");