Click here to Skip to main content
15,921,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how could i stored data form textbox of windowapplication to xml file using visual c#
Posted

For example
private void button1_Click(object sender, EventArgs e)
        {
            XmlWriter writer = XmlWriter.Create(@"F:\TEMP\xml.xml");

            writer.WriteStartElement("Personel");

            writer.WriteStartElement("IT");
            writer.WriteAttributeString("Name", textBox1.Text);
            writer.WriteElementString("Age", textBox2.Text);
            writer.WriteElementString("Occupation", textBox3.Text);
            writer.WriteEndElement();
            writer.Close();
        }

dont forget to include using System.Xml;
 
Share this answer
 
Comments
jia123m 10-Oct-10 0:36am    
its working than you!!!
jia123m 10-Oct-10 0:37am    
i mean thank you!!
jia123m 17-Oct-10 12:31pm    
hay!Heinzzy! yours code help me a lot i wanna save these xml data in to database plz help me again i m waiting for your response plz reply me soon
Example:
using System.Xml;

XmlTextWriter textWriter = new XmlTextWriter("Test.xml", null);

        textWriter.WriteStartDocument();
        textWriter.WriteStartElement("items");

        
            textWriter.WriteStartElement("items");
            textWriter.WriteStartAttribute("src");
            textWriter.WriteValue(txt1.Text);
            textWriter.WriteEndAttribute();      
            textWriter.WriteCData(txtDescription.Text);
            textWriter.WriteEndElement();
       


        textWriter.WriteEndElement();
        textWriter.WriteEndDocument();
        textWriter.Close();
 
Share this answer
 
v2

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