# Xml attributes problem

**URL:** <https://forum.kirupa.com/t/xml-attributes-problem/184705>\
**Category:** flash\
**Created:** [April 6, 2006, 11:53pm UTC](https://forum.kirupa.com/t/xml-attributes-problem/184705 "2006-04-06T23:53:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 6, 2006, 11:53pm UTC](https://forum.kirupa.com/t/xml-attributes-problem/184705/1 "2006-04-06T23:53:32Z")

</div>

Hi!

New on the forum (not on the web) and early questions 😃

I’m doing a website in Flash 8 in wich I need XML in order to show up users profiles. Well, there’s something I don’t know hot to do.  
I’m reading XML and passing nodes values to arrays. I get stuck in one of my nodes wich may have attributes.

This is the Xml code

```auto
<nombrePersonaje 2="Dihinimi">Juduth</nombrePersonaje>

```

And I have inside a for something like this for the values of the nodes (i.e. Juduth)

```auto
nombrePersonaje2* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;

```

That is fine for the value of that node but… HOW CAN I ACCESS THE ATTRIBUTE 2 from the Xml??

I thought in something like this

```auto
mlNode.childNodes*.childNodes[3].firstChild.nodeValue.attributes.2;

```

But then I realised that isn’t the correct way at all. I’ve found nothing through websites and I need it.

That’s all of you that reply

Nice to be in Kirupa’s forums

---

<div class="post-metadata">

**Author:** ![expensive\_pen](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/expensive_pen/32/554_2.png) [@expensive\_pen](https://forum.kirupa.com/u/expensive_pen)\
**Post date:** [April 7, 2006, 3:22am UTC](https://forum.kirupa.com/t/xml-attributes-problem/184705/2 "2006-04-07T03:22:05Z")

</div>

attriubutes is an associative array

but it seems you are trying to get the attributes of Judith node which isn’t really a node at all and certainly doesn’t have any attributes

```auto

xmlNode.childNodes*.childNodes[3].attributes["2"];

```

that will probably work

---

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 7:45am UTC](https://forum.kirupa.com/t/xml-attributes-problem/184705/3 "2006-04-07T07:45:34Z")

</div>

Nope

I’ll show the entire code for that piece

```auto
nombrePersonaje2 = [];

total = xmlNode.childNodes.length;

for (i=0; i<total; i++) {
//the following doesn´t work :D
nombrePersonaje2* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue.attributes["2"];
}

```

Then this reads the array position 0

```auto
nomPers2.text = nombrePersonaje2[0];

```

And this is the Xml

```auto
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<miembros>
    <miembro>
        <avatar>miembros/imgs/avatar/LaughingBull.jpg</avatar>
        <nombre>Laughing Bull</nombre>
      <personajes>1</personajes>
        <nombrePersonaje 2="Quistis">Juduth</nombrePersonaje>
      <raza>Hume</raza>
      <jobs>job1</jobs>
    </miembro>
    <miembro>
        <avatar>miembros/imgs/avatar/Hola.jpg</avatar>
        <nombre>Dos</nombre>
      <personajes>1</personajes>
        <nombrePersonaje 2="Quistis">Hola1</nombrePersonaje>
      <raza>Mithra</raza>
      <jobs>job2</jobs>
    </miembro>
    <miembro>
        <avatar>miembros/imgs/avatar/Adios.jpg</avatar>
        <nombre>Tres</nombre>
        <personajes>1</personajes>
      <nombrePersonaje 2="Quistis">Adios1</nombrePersonaje>
      <raza>Elveen</raza>
      <jobs>job3</jobs>
    </miembro>
</miembros>

```

---

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 7:50am UTC](https://forum.kirupa.com/t/xml-attributes-problem/184705/4 "2006-04-07T07:50:39Z")

</div>

Ok, I have it

Your piece of code was correct but I needed to adjust the line in order to get only the specific xml tag (without nodeValue)

Wrong code:

```auto
xmlNode.childNodes*.childNodes[3].firstChild.nodeValue.attributes["2"];

```

Good code:

```auto
xmlNode.childNodes*.childNodes[3].attributes["2"];

```

Thank’s, now I can think about a richer xml structure

---

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 7:57am UTC](https://forum.kirupa.com/t/xml-attributes-problem/184705/5 "2006-04-07T07:57:12Z")

</div>

Thank’s :thumb:

Now I can think about a richer xml structure
