Skip to main content

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";


  1. Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!
    web designing classes in chennai | web designing training institute in chennai
    web designing and development course in chennai | web designing courses in Chennai
    best institute for web designing in chennai | web designing course with placement in chennai
    Web Designing Class
    web designing course
    best institute for web designing


Post a Comment