Currently you're creating a new element using the document, but never actually adding it to the document. You're also trying to set an attribute where previously you had the text within the element itself.
Assuming you really do just want to update the element, I'd personally use LINQ to XML instead of XmlDocument
:
var doc = XDocument.Load("version.xml");
// Single() ensures there's only one such element
var element = doc.Descendants("Product").Single();
int currentValue = (int) element;
element.SetValue(currentValue + 1);
doc.Save("version.xml");
If you want to update all Product
elements, you should loop over doc.Descendants("Product")
with a foreach
loop.