Click here to Skip to main content
15,911,139 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
this code only make xml file.

C#
private void btnCreatexml_Click(object sender, EventArgs e)
        {
            XmlTextWriter xwriter = new XmlTextWriter("Employee.Xml",   Encoding.UTF8);
            xwriter.Formatting = Formatting.Indented;
            xwriter.WriteStartElement("Employees");
            xwriter.WriteStartElement("EmpInformation");
            xwriter.WriteStartElement("name");
            xwriter.WriteString(textBox1.Text);
            xwriter.WriteEndElement();
            xwriter.WriteStartElement("age");
            xwriter.WriteValue(textBox2.Text);
            xwriter.WriteEndElement();
            xwriter.WriteStartElement("email");
            xwriter.WriteString(textBox3.Text);
            xwriter.WriteEndElement();
            xwriter.WriteEndElement();
            xwriter.WriteEndElement();
            xwriter.Close();
        }

and this code is for store multy recodes.but i want to edit any recode from xml file what i have plz help me on this topic thnx


C#
private void btnAddrecord_Click(object sender, EventArgs e)
        {
            XmlDataDocument doc = new XmlDataDocument();
            doc.Load("Employee.Xml");

            XmlNode EmpInformation = doc.CreateElement("EmpInformation");
            XmlNode name = doc.CreateElement("name");
            name.InnerText = textBox1.Text.Trim();
            EmpInformation.AppendChild(name);
            XmlNode age = doc.CreateElement("age");
            age.InnerText = textBox2.Text.Trim();
            EmpInformation.AppendChild(age);
            XmlNode email = doc.CreateElement("email");
            email.InnerText = textBox3.Text.Trim();
            EmpInformation.AppendChild(email);
            doc.DocumentElement.AppendChild(EmpInformation);
            doc.Save("Employee.Xml");
        }
Posted
Updated 14-Jul-15 1:12am
v2

This looks like you're trying to create a place to store database like data which is a big, big task to do. Why not using something ready made, for example RaptorDB - the Document Store[^].

There are a lot of choices out there. Even free SQL Databases such as SQL Server Express edition. All depending what you're after. :)
 
Share this answer
 
You can fill a DataSet to read and write XML file:
https://msdn.microsoft.com/en-us/library/ekw4dh3f.aspx[^]
https://www.daniweb.com/software-development/csharp/threads/343670/use-of-xml-file-in-c-instead-of-database[^]
Using such DataSet you can bind your data to any data-control, like Grid and edit it as you want...
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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