J'ai appris récemment à importer du XML dans Flash mais un problème persiste. Je vous montre :
Le XML
<?xml version='1.0' encoding="UTF-8" ?> <racine> <texte mot="txt1"> txt1 txt1 txt1 txt1 txt1 txt1 txt1 txt1 txt1 txt1 txt1 txt1 txt1 txt1 txt1 txt1 </texte> <texte mot="texte 2"> texte 2 texte 2 texte 2 texte 2 texte 2 texte 2 texte 2 texte 2 </texte> <texte mot="txt n3"> txt n3 txt n3 txt n3 txt n3 txt n3 txt n3 txt n3 txt n3 txt n3 txt n3 </texte> <texte mot="rapidité"> rapidité &édg "''g( -è è__àgfd çà)=^ù sdf !*$£µ gdfg %<< </texte> <texte mot="anticonstitutionnellement"> anticonstitutionnel anticonstitutionnel anticonstitutionnel </texte> </racine>
Actionscript
/* Importation XML */
Fichier_XML = new XML();
Fichier_XML.ignoreWhite = true;
Fichier_XML.load("motsclef5.xml");
/* J'affiche mes mots-clef */
Fichier_XML.onLoad = function(Reussite) {
if (Reussite) {
x = Fichier_XML.firstChild;
cmot1.mot1 = x.childNodes[0].attributes.mot;
cmot2.mot2 = x.childNodes[1].attributes.mot;
cmot3.mot3 = x.childNodes[2].attributes.mot;
cmot4.mot4 = x.childNodes[1].attributes.mot;
cmot5.mot5 = x.childNodes[4].attributes.mot;
}
else { zonetxt = "Erreur lors du chargement du fichier XML"; }
};
Et en fait ici, mes attributs apparaissent bel et bien dans "mot1" "mot2" "mot3" et "mot4" mais pas dans "mot5".
Dès que je veux charger un autre enfant que les trois premiers, que ce soit pour les attributs ou pour le contenu, j'obtiens : undefined
Quelqu'un a une idée?


Haut











