# Reading XML attribues dynamically

**URL:** <https://forum.kirupa.com/t/reading-xml-attribues-dynamically/322157>\
**Category:** flash\
**Created:** [May 12, 2011, 1:12pm UTC](https://forum.kirupa.com/t/reading-xml-attribues-dynamically/322157 "2011-05-12T13:12:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![supersaj](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@supersaj](https://forum.kirupa.com/u/supersaj)\
**Post date:** [May 12, 2011, 1:12pm UTC](https://forum.kirupa.com/t/reading-xml-attribues-dynamically/322157/1 "2011-05-12T13:12:59Z")

</div>

Can anyine help with this problem, I’m new to flash and maybe I’m just missing the obvious.  
I have the following XML code:

\<item1\>  
\<height1\>  
\<width800\>60 \</width800\>  
\<width900\>65 \</width900\>  
\<width1000\>69 \</width1000\>  
\<width1100\>74 \</width1100\>  
\<width1200\>78 \</width1200\>  
\<width1300\>83 \</width1300\>  
\</height1\>  
\<height2\>  
\<width800\>64 \</width800\>  
\<width900\>70 \</width900\>  
\<width1000\>75 \</width1000\>  
\<width1100\>80 \</width1100\>  
\<width1200\>84 \</width1200\>  
\<width1300\>89 \</width1300\>  
\</height2\> etc…

and using the following lines I can trace the value.

function SortCost(itemInput:XML):void {  
var itemBasePrice:XMLList = itemInput.height800.width800;  
trace (itemBasePrice);

this returns the value 60. - O.K.

The problem is that I need to create the XMLList variable dynamically through code so that I can select various heights and widths in string variables, then substitute them in the XMLList variable to extract the correct data.

I know this doesn’t work but code something like this:

var ht:String = “height1”;  
var wd:String = “width800”;  
function SortCost(itemInput:XML):void {  
var itemBasePrice:XMLList = itemInput.ht.wd;  
trace (itemBasePrice);
