i have an xml file called image.xml
0
0
I'm not sure if I understood it correctly, but try something like this:
XmlDocument xml = new XmlDocument();
xml.LoadXml("..."); // or xml.Load("yourfile.xml");
string name = "Gallery1";
XmlElement gallery = xml.SelectSingleNode("//" + name) as XmlElement;
if(gallery == null)
{
gallery = xml.CreateElement(name);
gallery.InnerText = "1";
xml.DocumentElement.AppendChild(gallery);
}
else
{
gallery.InnerText = (Int32.Parse(gallery.InnerText) + 1).ToString();
}