Creating variables in a loop and assigning them non empty XML values

Here is the structure of the XML file:


<xmlfile>
<page></page>

<page>
 <source></source>
 </page>
</xmlfile>

Some “page” nodes contain the extra “source” node. What I’m currently doing is looping through all the page nodes and looking for any source nodes. If there is a source node, I create a variable, and want to assign it a value of the contents of the “source” (HTML).

Here’s the AS:

numNodes = myXML.firstChild.childNodes.length;
        for(i=0; i<numNodes; i++) {
            pSource = myXML.firstChild.childNodes*.firstChild.nextSibling;
            if (pSource != null) {
                this["page_source"+i] = pSource;
                trace("page_source"+i);
            }
        }

The variables are named according to the page they’re on, i.e. the above example would be page_source2 since no source node is in the first page. So, I want page_source2 to hold the value of the node, but all I’m getting back is the page_source name. How can I get the dynamically created variable to hold the node value?