XML et saut de ligne (écriture du fichier en C#)
Bonjour à tous, J'ai un petit problème pas bien méchant mais sa me gêne...
Je créer une fichier Xml a partir du code suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| // II. Ajout
// 1. Créer un nouvel élément patch.
XmlElement newElem = xmldoc.CreateElement("patch");
// Ajouter l'attribut Id.
XmlAttribute newAttr = xmldoc.CreateAttribute("id");
newAttr.Value = "5";
newElem.Attributes.Append(newAttr);
// Ajouter l'attribut Nom.
XmlAttribute newAttr1 = xmldoc.CreateAttribute("nom");
newAttr1.Value = "5";
newElem.Attributes.Append(newAttr1);
// Ajouter l'attribut Url.
XmlAttribute newAttr2 = xmldoc.CreateAttribute("url");
newAttr2.Value = "5";
newElem.Attributes.Append(newAttr2);
// Ajouter l'attribut versions.
XmlAttribute newAttr3 = xmldoc.CreateAttribute("ver");
newAttr3.Value = "5";
newElem.Attributes.Append(newAttr3);
// 2. Ajouter le nouvel élément à la fin de la liste des patch.
xmldoc.DocumentElement.AppendChild(newElem);
// 3. Enregistrer le XML modifié dans un fichier au format UTF8.
xmldoc.PreserveWhitespace = true;
XmlTextWriter wrtr = new XmlTextWriter("patchs.xml", Encoding.UTF8);
xmldoc.WriteTo(wrtr);
wrtr.Close(); |
Mon fichier de base est :
Code:
1 2 3 4 5 6
| <?xml version="1.0" encoding="utf-8" ?>
<Versions>
<patch ver="0.0.0.0" id="0" nom="Esthar.eo" />
<patch ver="0.0.0.0" id="1" nom="Esthar.eo" url="http://esthar-online.com/patchs/"/>
<patch ver="0.0.0.0" id="2" nom="test.txt" url="http://esthar-online.com/patchs/"/>
</Versions> |
Tou beau et lisible le problème c'est que mon nouveau fichier lui met tout sur une ligne et j'aimerais qu'il saute des lignes pour faciliter sa lecture utilisateur
Code:
<?xml version="1.0" encoding="utf-8"?><Versions><patch ver="0.0.0.0" id="0" nom="Esthar.eo" /><patch ver="0.0.0.0" id="1" nom="Esthar.eo" url="http://esthar-online.com/patchs/" /><patch ver="0.0.0.0" id="2" nom="test.txt" url="http://esthar-online.com/patchs/" /><patch id="5" nom="5" url="5" ver="5" /></Versions>
Bien que ce ne change en rien mon scripte sa me gêne T_T (Ok maniaco spotted :aie: )
Si vous avez des idées ?