# Attributes from XML nodes

**URL:** <https://forum.kirupa.com/t/attributes-from-xml-nodes/186475>\
**Category:** flash\
**Created:** [April 21, 2006, 3:12pm UTC](https://forum.kirupa.com/t/attributes-from-xml-nodes/186475 "2006-04-21T15:12:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daffy\_dowden](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/daffy_dowden/32/2371_2.png) [@daffy\_dowden](https://forum.kirupa.com/u/daffy_dowden)\
**Post date:** [April 21, 2006, 3:12pm UTC](https://forum.kirupa.com/t/attributes-from-xml-nodes/186475/1 "2006-04-21T15:12:49Z")

</div>

Just a quick question:  
Is there anyway to get the number of attributes an xml node has.

I’m just not fond of the way you have to loop through an xml node ala  
[http://www.macromedia.com/devnet/flash/articles/tools\_xmlobject.html](http://www.macromedia.com/devnet/flash/articles/tools_xmlobject.html)

for (attr in this.childNodes\*.attributes) {  
…  
}

Is there nothing like childNodes\*.attributes.length???

cheers, Rich

:pope: - These smilies crack me up

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [April 21, 2006, 3:28pm UTC](https://forum.kirupa.com/t/attributes-from-xml-nodes/186475/2 "2006-04-21T15:28:56Z")

</div>

> [@Documentation](#):
>
> for (attr in doc.firstChild.attributes) {  
> trace (attr + " = " + doc.firstChild.attributes[attr]);  
> }

According to the help files you could modify it as

```auto
counter = 0;
for (attr in this.childNodes*.attributes) {
    counter++;
}
trace(counter)

```

---

<div class="post-metadata">

**Author:** ![daffy\_dowden](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/daffy_dowden/32/2371_2.png) [@daffy\_dowden](https://forum.kirupa.com/u/daffy_dowden)\
**Post date:** [April 22, 2006, 9:31am UTC](https://forum.kirupa.com/t/attributes-from-xml-nodes/186475/3 "2006-04-22T09:31:52Z")

</div>

Thought that might be the only way to do it.  
I was just hoping the attributes property would have a method to get the number of attributes for that node.

Cheers!  
Daf :thumb:
