How to save TextBox value to XML file in ASP.Net

Last Reply on Jan 03, 2014 05:25 AM By Pradip

Posted on Jan 03, 2014 05:20 AM

How to save XML file in windows programming??

I have two textboxes..Uname and Pwd

now when I click on login button it gives me XML string like..<XML?.............>

now how to store this XML in my windows project??

Do you know??

Thanks!!

Posted on Jan 03, 2014 05:25 AM Modified on on Jan 03, 2014 05:26 AM

Try This

 

StringWriter stringwriter = new StringWriter();
XmlTextWriter xmlTextWriter = new XmlTextWriter(stringwriter);
xmlTextWriter.Formatting = Formatting.Indented;
xmlTextWriter.WriteStartDocument();
xmlTextWriter.WriteStartElement("root");
xmlTextWriter.WriteStartElement("information");
xmlTextWriter.WriteElementString("User Name", "User Name");
xmlTextWriter.WriteElementString("Password", "txtpass.txt");
xmlTextWriter.WriteEndElement();            
xmlTextWriter.WriteEndDocument();
XmlDocument docSave = new XmlDocument();
docSave.LoadXml(stringwriter.ToString());
//write the path where you want to save the Xml file
docSave.Save(@"c:\Information.xml");

 or

Refer

http://visualcsharptutorials.com/net-framework/writing-xml-file