# Using String to reference variable name in XML?

**URL:** <https://forum.kirupa.com/t/using-string-to-reference-variable-name-in-xml/285623>\
**Category:** Uncategorized\
**Created:** [April 3, 2009, 2:54am UTC](https://forum.kirupa.com/t/using-string-to-reference-variable-name-in-xml/285623 "2009-04-03T02:54:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ohbeewan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ohbeewan/32/1745_2.png) [@ohbeewan](https://forum.kirupa.com/u/ohbeewan)\
**Post date:** [April 3, 2009, 2:54am UTC](https://forum.kirupa.com/t/using-string-to-reference-variable-name-in-xml/285623/1 "2009-04-03T02:54:32Z")

</div>

Is there, uh, a way to use the value of a string to reference a variable name?

I’m trying to dynamically assign XML node names and attributes using a string value, I tried something like this:

```auto

**var sItem:String = "book"** ; // to be dynamically assigned
for (var i:uint; i < _xml.book.length(); i++) {
  aList.push(_xml.**(this[sItem])***.@title);
}

```

But this throws the error:  
ReferenceError: Error #1069: Property book not found on … and there is no default value.

Thanks, ob
