ChildNodes

jobrider Messages postés 10 Date d'inscription lundi 23 avril 2007 Statut Membre Dernière intervention 16 septembre 2008 - 23 avril 2007 à 16:23
Darkrats Messages postés 212 Date d'inscription mardi 2 novembre 2004 Statut Membre Dernière intervention 12 mai 2008 - 24 avril 2007 à 10:36
hello tous !

je galèèère...
j'essaille de récuperer  une varable dans mon flash depuis mon xml.
rien ne sort !
HELP

voila mon xml :
<?xml version='1.0' encoding='UTF-8'?><main><identite id_membre="88" pseudo="LABREIZH" /><identite id_membre="87" pseudo="noesis" /></main>

et dans mon flash :

document = new XML(); //création de l'objet XML
document.load("php_xml2.php"); //charge le document
document.ignoreWhite=true; //ignorer les sauts de ligne

document.onLoad=function(){

txt1=document.firstChild.childNodes[0].childNodes[1].childNodes[1].attributes.id_membre;
txt2=document.firstChild.childNodes[0].childNodes[0].childNodes[1].attributes.pseudo;

}

1 réponse

Darkrats Messages postés 212 Date d'inscription mardi 2 novembre 2004 Statut Membre Dernière intervention 12 mai 2008 1
24 avril 2007 à 10:36
Salut,

Ton problème est principalement un problème de ciblage des noeuds.
Voici ton fichier xml :
<?xml version= '1.0' encoding='UTF-8'?>
<main> <!-- childNodes[0] -->
<identite id_membre="88" pseudo="LABREIZH" /> <!-- childNodes[0].childNodes[0] -->
<identite id_membre="87" pseudo="noesis" /> <!-- childNodes[0].childNodes[1] -->
</main>

En commentaire, j'ai mis la hiérarchie de ton fichier, essaie maintenant d'obtenir les informations via ce code :
Code :
    document.onLoad =function(){
        txt1 = document.firstChild.childNodes[0].attributes.id_membre;

        txt2 = document.firstChild.childNodes[0].attributes.pseudo;

        txt3 = document.firstChild.childNodes[1].attributes.id_membre;
        txt4 = document.firstChild.childNodes[1].attributes.pseudo;        trace("Membre du premier noeud :: id " + txt1 + " :: son pseudo " + txt2);

        trace("Membre du second noeud :: id " + txt3 + " :: son pseudo " + txt4);
    }
Fin du code
Normalement, tu devrais recevoir correctement les informations.

--------- Darkrats ---------
la loi est dure mais c'est la loi
 -------- Infograpix --------
0
Rejoignez-nous