howdy,
im trying to pull attributes from my xml file for use in a dynamic text field but cant seem to get the actionscript dialed in properly…maybe YOU can help!
i have a php script which parses the data as attributes rather than nodes…so my actionscript must use these attributes!
my xml file is parsed as such:
<cars>
<car make=“lambo” model=“testarosa” year=“2002” mileage=“30k” />
<car make=“ferrari” model=“360” year=“2003” mileage=“40k” />
</cars>
and im trying to write a simple xml actioncript which assigns those attributes to my dynamic text fields. since its merely text, i dont need any preload script or anything fancy. i’ve heard that xml attributes actually load a bit faster than nodes anyway so rather than muck with my php script, im prone to make the changes in my actionscript.
my simple (erroneous) actionscript is as follows:
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success) {
if (success) {
var p = myXML.firstChild.childNodes;
make_txt.text = p[0].childNodes[0].firstChild.attributes.make;
model_txt.text = p[0].childNodes[0].firstChild.attributes.model;
year_txt.text = p[0].childNodes[0].firstChild.attributes.year;
mileage_txt.text = p[0].childNodes[0].firstChild.attributes.mileage;
}
}
myXML.load(“xmltest.xml”);
p = 0;
the dynamic text fields come up UNDEFINED every single time…any ideas or suggestions???
thanks in advance!