Hi Vincent,
a couple of points pop out:
1. You are not loading any data into the XmlDocument object, you need to add
a line like:
xmlDoc.Load(txtReader);
2. Your XPath query is not correct, instead of being "entry" it should be
"/gconf/entry"
3. You ar enot saving your changes back to file, you are only modifying
them in memory.
Below is some code that is a modified version of what you posted, it should
work for you:
XmlDocument xmlDoc = new XmlDocument();
String path = "background.xml";
xmlDoc.Load(path);
XmlNodeList nodeList = xmlDoc.SelectNodes("/gconf/entry");
foreach (XmlNode node in nodeList)
{
node.Attributes["mtime"].Value =
(Int32.Parse(node.Attributes["mtime"].Value) + 1).ToString();
}
xmlDoc.Save("background.xml");
Hope that helps
Mark Dawson
http://www.markdawson.org
"Vincent" wrote:
Hi!
I'm quite new to C#, and I want to edit an XML file. I followed the
HOW-TO here :
http://support.microsoft.com/default...b;en-us;317666 but it
didn't help that much. I work under Linux and MonoDevelop. The file I
want to modify is here : http://pastebin.com/542434
Let's say that I want to edit the "mtime" field. I use this piece of
code : http://pastebin.com/542437
Actually, I don't get any compilation error, but I don't get any
modification as well... Does somedy see an error somewhere in the code
?
Thanks in advance for your help!
Vincent.