Juduth
April 6, 2006, 11:53pm
1
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
<nombrePersonaje 2="Dihinimi">Juduth</nombrePersonaje>
And I have inside a for something like this for the values of the nodes (i.e. Juduth)
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
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
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
xmlNode.childNodes*.childNodes[3].attributes["2"];
that will probably work
Juduth
April 7, 2006, 7:45am
3
Nope
I’ll show the entire code for that piece
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
nomPers2.text = nombrePersonaje2[0];
And this is the Xml
<?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>
Juduth
April 7, 2006, 7:50am
4
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:
xmlNode.childNodes*.childNodes[3].firstChild.nodeValue.attributes["2"];
Good code:
xmlNode.childNodes*.childNodes[3].attributes["2"];
Thank’s, now I can think about a richer xml structure
Juduth
April 7, 2006, 7:57am
5
Thank’s :thumb:
Now I can think about a richer xml structure