katyjack
asked on
Retrieving XML Node Values and Node Names using Actionscript
I've got an XML file that I'm retrieving using Flash Remoting. That part is working fine, but in the function that I run once I get the data, I'd like to take the node names and the node values and place them both in an array to use later in the program. I'm having a difficult time retrieving the node value. I've attached a simplified version of my code so you can see what I'm doing and where the problem is occuring.
Thanks for any help - I'm stumped.
Thanks for any help - I'm stumped.
function gotConfig(re:ResultEvent) {
var vConfigXML = re.result;
var tempconfig_xml:XML = new XML(vConfigXML);
tempconfig_xml.ignoreWhite = true;
trace("tempconfig_xml: " + tempconfig_xml);
//result
/* <?xml version="1.0" encoding="UTF-8"?>
<config><bkgimage>images/bkg_browsevideo.jpg</bkgimage><headerimage>images/header.png</headerimage></config> */
var config_xml:XML = tempconfig_xml.childNodes[1].childNodes;
trace("config_xml: " + config_xml);
// result
/* config_xml: <bkgimage>images/bkg_browsevideo.jpg</bkgimage>,<headerimage>images/header.png</headerimage> */
var var1 = tempconfig_xml.childNodes[1].childNodes[1].nodeName;
var var2 = tempconfig_xml.childNodes[1].childNodes[1].nodeValue;
var var3 = tempconfig_xml.childNodes[1].childNodes[1]
trace("var1: " + var1); // var1: bkgimage
trace("var2: " + var1); // var2: bkgimage -- I need it to be images/bkg_browsevideo.jpg
trace("var3: " + var3);
//<bkgimage>images/bkg_browsevideo.jpg</bkgimage>
stop();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER