Click here to Skip to main content
15,844,387 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am developing a web application using C# .net, can you give me some idea on how to store data from textbox to XML file in, like when user enters some data into the textbox's and click's on the submit button, all the data which the user entered into the textbox's should be stored in the XML file.

Share this answer
Monjurul Habib 9-Jul-11 5:17am    
nice link, my 5.
mhamad zarif 9-Jul-11 5:57am    
very nice link, my 5.
Abhinav S 10-Jul-11 1:21am    
As simple as that - 5.
Try to bind XML file to your Textbox value for Saving Data.
DataSet ds = new DataSet();
ds.Tables[0].Rows[0]["NodeName"] =textbox1.Text; 
Share this answer
Sachin__Sharma 9-Jul-11 6:28am    
my +5 good answer.
RaviRanjanKr 9-Jul-11 6:30am    
Thanks Sachin.
You can persist (store and load to/from file/stream/string) data structure of any complexity without any special XML-related effort using Data Contract. You should better prefer it to any other serialization method due to its data-driven matter, lack of intrusive programming, good support of compatibility, support of world-unique schema and ease of use.

Please see:[^].

See my past answer where I advocate this great approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating a property files...[^].

Share this answer
Abhinav S 10-Jul-11 1:21am    
Good answer. My 5.
Sergey Alexandrovich Kryukov 10-Jul-11 1:30am    
Thank you, Abhinav.
Share this answer
Try the following simple code :

public String s = Server.mappath( "\\Titles.xml");

XmlTextWriter writer = new XmlTextWriter(s, null);
               writer.WriteElementString("label", textBox1.Text);


Where s is the name of your xml file that is you have.
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