Skip to content

Writing xml to a file.. overwriting previous data

Mohit Juneja

Asked Mar 27, 2013, 2:53 AM EDT1 answer
Share
LinkedInX
Whenever i am trying to execute this code .. it  overwrites my previous XML elements... 

 XmlDocument Doc = new XmlDocument();
            XmlDeclaration dec = Doc.CreateXmlDeclaration("1.0", null, null);
            Doc.AppendChild(dec);
            XmlElement DocRoot = Doc.CreateElement("Feedback");
            Doc.AppendChild(DocRoot);


            XmlNode server = Doc.CreateElement("Message");
            DocRoot.AppendChild(server);
            server.InnerText = this.TextBox1.Text;


            Doc.Save(Server.MapPath("mm.xml"));

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Suthish Nair
    0
    You need to do a for loop on each node and find the place to add new one.. Lots of XML related tutorial's available here. Check Our Recommended Solutions below your thread..
    0