XML

archette_b Messages postés 4 Date d'inscription mardi 17 août 2004 Statut Membre Dernière intervention 20 août 2004 - 17 août 2004 à 13:47
archette_b Messages postés 4 Date d'inscription mardi 17 août 2004 Statut Membre Dernière intervention 20 août 2004 - 17 août 2004 à 14:24
Hello tout le monde,
je charge un fichier XML mais lorsque je veux afficher les valeurs dans unc hamp de texte j'ai "undefined" ?
Voilà mon code :
xmlDoc = new XML();
xmlDoc.ignoreWhite = true;
xmlDoc.load("essai.xml");
if (xmlDoc.loaded) {
trace("fichier XML chargé.");
}
_root.nom.text = xmlDoc.firstChild.childNodes[0].attributes.nom;
_root.age.text = xmlDoc.firstChild.childNodes[0].attributes.age;
fichier XML :
(il est ien encodé en UTF-8)
<racine>

</racine>
Merci pr votre aide

1 réponse

archette_b Messages postés 4 Date d'inscription mardi 17 août 2004 Statut Membre Dernière intervention 20 août 2004
17 août 2004 à 14:24
c'est bon j'ai trouvé.
xmlDoc.onLoad = function(flag) {
if (flag) {
trace("OK");
nomV = xmlDoc.firstChild.childNodes[0].attributes.nom;
ageV = xmlDoc.firstChild.childNodes[0].attributes.age;
}else {
trace("pas OK");
}
}
il fallait attendre que le ficier soit chargé ;-) ...
0
Rejoignez-nous