modifier le valeur d'un noeud xml
Bonjour,
Je veux modifier la valeur d'un noeud dans mon fichier xml :
voici mon fichier xml :
Code:
1 2 3 4 5 6
|
<?xml version="1.0"?>
<params att="false">
<param1>def</param1>
<param2>abc</param2>
</params> |
Voici le code qui j'écris mais ça marche pas :cry:
Code:
1 2 3 4 5 6 7 8
|
XmlDocument xmlDoc = new XmlDocument();
string file = "chemin de mon fichier xml";
xmlDoc.Load(file);
xmlDoc.SelectSingleNode("/params/param1").InnerText = "aaa";
xmlDoc.SelectSingleNode("/params/param2").InnerText = "bbb";
xmlDoc.SelectSingleNode("/params").Attributes["att"].Value = "true"; |