# Using XML Attributes?!?!?!?!

**URL:** <https://forum.kirupa.com/t/using-xml-attributes/227543>\
**Category:** flash\
**Created:** [May 31, 2007, 4:03am UTC](https://forum.kirupa.com/t/using-xml-attributes/227543 "2007-05-31T04:03:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vmarvaso](https://avatars.discourse-cdn.com/v4/letter/v/df788c/32.png) [@vmarvaso](https://forum.kirupa.com/u/vmarvaso)\
**Post date:** [May 31, 2007, 4:03am UTC](https://forum.kirupa.com/t/using-xml-attributes/227543/1 "2007-05-31T04:03:17Z")

</div>

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! 🍺
