Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was able to figure out the answer and was able to make my 1st trial with xml a <strong>success</strong>. I was trying to work with xml and C#. So I started on with a small thing:</p> <blockquote> <ol> <li>A windows form to accept Employee Department, name, and Emp No.</li> <li>On the press of "Submit" button the xml will be written, then all textbox will be cleared, and xml will be displayed to the user.</li> </ol> </blockquote> <p>Here's the <strong>working</strong> code of button click.</p> <pre><code>private void button1_Click(object sender, EventArgs e) { string path = "employee.xml"; if (File.Exists(path)) { // to append a new user having reset the textboxes XDocument doc = XDocument.Load(path); XElement xe = new XElement("user", new XElement("department", textBox1.Text), new XElement("name", textBox2.Text), new XElement("empno", textBox3.Text) ); doc.Root.Add(xe); doc.Save(path); } else { new XDocument( new XElement("users", new XElement("user", new XElement("department", textBox1.Text), new XElement("name", textBox2.Text), new XElement("empNo", textBox3.Text) ) ) ).Save(path); } textBox1.Text=""; textBox2.Text=""; textBox3.Text=""; MessageBox.Show("Data added successfully","Done!!",MessageBoxButtons.OK); this.button1.Enabled=false; f2=new Form2(); f2.FormClosed += Form2_FormClosed; f2.Show(); } </code></pre> <p>Sadly I was not able to get any help from here(Stackoverflow) for editing the xml... so I decided to share the code with everybody here. Maybe this answer will help someone new like me.</p> <p>This code could be modified with better skills and utilities, and if somebody has time &amp; interest in helping a newbie then please do come forward.</p> <p>Gud luck to all newbies here :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload