Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
actually i load my text field data into a xml file
but when i execute my programe next time it will append my text field data into xml file which i dont want .i want that next time xml store new data not append that data in to previous data

my code is:-

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(@"E:\\grabone1\\grabone1\\Insert.xml");
XmlNode node = xmldoc.SelectSingleNode("records");
XmlNode recordnode=node.AppendChild(xmldoc.CreateNode(XmlNodeType.Element,"reocord",""));
recordnode.AppendChild(xmldoc.CreateNode(XmlNodeType.Element, "tlpl06m", "")).InnerText = txttplm.Text;
recordnode.AppendChild(xmldoc.CreateNode(XmlNodeType.Element, "tlpl06f", "")).InnerText = txttplf.Text;
recordnode.AppendChild(xmldoc.CreateNode(XmlNodeType.Element, "tlpl06", "")).InnerText = txttpltotal.Text;
recordnode.AppendChild(xmldoc.CreateNode(XmlNodeType.Element, "catagory", "")).InnerText = txtcatgory.Text;

xmldoc.Save(@"E:\\grabone1\\grabone1\\Insert.xml");
Posted

1 solution

Application is a senseless tag. How about C#, XML, Winforms ?


cshuhh wrote:
XmlNode recordnode=node.AppendChild(xmldoc.CreateNode(XmlNodeType.Element,"reocord",""));


Perhaps you need to RTFM. You append a node, but you don't want to do that ? I'd use an XmlTextWriter to simplify just overwriting your current document. Then I'd read a book and learn something instead of copying code at random over the web and getting confused when it does what you ask it, instead of what you hoped it might.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900