# How to get the value of the xml attributes

**URL:** <https://forum.kirupa.com/t/how-to-get-the-value-of-the-xml-attributes/249783>\
**Category:** flash\
**Created:** [January 22, 2008, 3:54pm UTC](https://forum.kirupa.com/t/how-to-get-the-value-of-the-xml-attributes/249783 "2008-01-22T15:54:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kitsunegari](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kitsunegari](https://forum.kirupa.com/u/kitsunegari)\
**Post date:** [January 22, 2008, 3:54pm UTC](https://forum.kirupa.com/t/how-to-get-the-value-of-the-xml-attributes/249783/1 "2008-01-22T15:54:57Z")

</div>

Hi

I would like to get the information of an xml file so that I can show it in a clip.

I can import my xml file and print out all of its data with trace() but I can’t make a simple to print the values the attributes of each node.

Here is my very simple xml file, called doc.xml

```auto
<myroot>
    <person name="foo" age="18" />
    <person name="bar" age="19" />
</myroot>

```

My loading function for the xml file works, but not the one with my loop to get the attributes values.

```auto

// LOADING OF THE XML (works well)
var loader:URLLoader = new URLLoader();
var adress:URLRequest = new URLRequest ("doc.xml");

loader.load(adress);

loader.addEventListener(Event.COMPLETE, loadXML);

function loadXML(eventObject:Event){
    var xml = new XML(eventObject.target.data);
    trace(xml);
  
  }

```

```auto

// XML ATTRIBUTES VALUES
// error 1120: Access of undefined property xml.
function printXML(eventObject:Event){
    
    var myarray = xml.firstChild.childNodes;
    
    for (var i = 0; i < myarray.length; i++)
    {
        var current = myarray*;
        trace(current);
    
    }
}

```

What do I have to modify in my printXML function so that I can get in my loop the value of the attributes of each nodes?

many thanks for your help
