Update XML Node value using C#

Update the XML document by passing the value to it, updating the specific node of the XML document and replacing the existing value.

Here I am updating the date node in the XML document that will be updated while I have entered the text and click the button

update XML using C#

XML format : XMLFile1.xml




using System;
using System.Web;
using System.Xml;

namespace XMLINS
    public partial class WebForm1 : System.Web.UI.Page
        protected void Button1_Click(object sender, EventArgs e)
            XmlDocument doc = new XmlDocument();

            XmlNodeList aDateNodes = doc.SelectNodes("/All_batches/Date");
            foreach (XmlNode aDateNode in aDateNodes)
                XmlAttribute DateAttribute = aDateNode.Attributes["Date"];
                aDateNode.InnerText = TextBox1.Text;
            Label1.Text = "XML updated Successfully";