Reading XML attribues dynamically

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);