# Reading Values from Attribute with for Loop

**URL:** <https://forum.kirupa.com/t/reading-values-from-attribute-with-for-loop/49847>\
**Category:** flash\
**Created:** [April 27, 2004, 5:14am UTC](https://forum.kirupa.com/t/reading-values-from-attribute-with-for-loop/49847 "2004-04-27T05:14:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashishchandras](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@ashishchandras](https://forum.kirupa.com/u/ashishchandras)\
**Post date:** [April 27, 2004, 5:14am UTC](https://forum.kirupa.com/t/reading-values-from-attribute-with-for-loop/49847/1 "2004-04-27T05:14:04Z")

</div>

Hi,  
I want to read attributes values from an XML file using an array. Here is the sample script which narrates my problem. Its fetching the values from the first node only and displays the same values twice.  
M  
22/121980  
M  
22/121980

Somewhere i am making a mistake in this Loop…can anybody works out where???pls,thanx

var oXML = new XML();  
oXML.parseXML("\<reportdatas\>\<reportdata gender=“M” dateofbirth=“22/12/1980” address=“XYZ” /\>\<reportdata gender="M"dateofbirth=“12/05/1982"address=“XYZ” /\>\</reportdatas\>”);  
// Grab attribute names  
var a = oXML.firstChild.firstChild.attributes;  
// Enumerate name/value pairs  
len = oXML.firstChild.childNodes.length  
//trace(len)  
attValue = [];

for(i=0; i\<len; i++){  
for(att in a){  
attValue\* = eval(“a.” + att);   
trace(attValue\*);  
}  
}

Ashish
