Traversing XML and storing into an Object

say I have an XML like this (store in variable: XMLDATA):

<params>
<Tom>23 years old</Tom>
<Bill>24 years old</Bill>
</params>

how can I make a for loop to automate the process of assigning all values to an object (named result) such that:

result.Tom = “23 years old”
result.Bill = “24 years old”

I did try to use something like below (but it failed)

for (var pname:String in XMLDATA)
result[root[pname].name()] = root[pname].toString()