Bonjour,
J'ai un petit soucie j'aimerai creer un fichier xml qui ressemblerai à sa :
<?xml version="1.0" encoding="utf-8"?>
<profils>
<parametre id="defaut">
<poids>0</poids>
<sexe>1</sexe>
</parametre>
<parametre id="toto">
<poids>51</poids>
<sexe>1</sexe>
</parametre>
</profils>
j'ai donc écrit dans ma fonction :
/*fot(cpt = 0; cpt < list_profil.Count ; cpt++)
{*/
//--------------------Première partie-----------------------------
XmlTextWriter.WriteStartElement("parametre");
XmlTextWriter.WriteAttributeString("id", list_profil[0].get_nom());
XmlTextWriter.WriteStartElement("poids");
XmlTextWriter.WriteString(list_profil[0].get_poids());
XmlTextWriter.WriteEndElement();
XmlTextWriter.WriteStartElement("sexe");
XmlTextWriter.WriteString(list_profil[0].get_sexe());
XmlTextWriter.WriteEndElement();
XmlTextWriter.WriteEndElement();
XmlTextWriter.WriteEndElement();
//--------------------Seconde partie-----------------------------
XmlTextWriter.WriteStartElement("parametre");
XmlTextWriter.WriteAttributeString("id", list_profil[1].get_nom());
XmlTextWriter.WriteStartElement("poids");
XmlTextWriter.WriteString(list_profil[1].get_poids());
XmlTextWriter.WriteEndElement();
XmlTextWriter.WriteStartElement("sexe");
XmlTextWriter.WriteString(list_profil[1].get_sexe());
XmlTextWriter.WriteEndElement();
XmlTextWriter.WriteEndElement();
XmlTextWriter.WriteEndElement();
// }
Ma première partie fonctionne parfaitement quand j'enlève ma deuxième partie (sans compter les
XmlTextWriter.WriteEndElement();
de la première partie). Mais quand je rajoute ma seconde partie (ou une boucle) il y a une erreur à :
XmlTextWriter.WriteStartElement("parametre");
Si quelqu'un connais la solution à mon problème,
Merci de votre aide !