Add new node(Element) in existing xml file in C#.Net
first make form like :

- now double click on button and write code like :
///////////////////////// CODE ////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Forms;
namespace Xml_File_Operation
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
XmlDocument xdoc1 = new XmlDocument();
xdoc1.Load("C:\\Users\\Nirav\\Desktop\\people1.xml");
XmlNode person = xdoc1.CreateElement("person");
XmlNode name = xdoc1.CreateElement("name");
name.InnerText = textBox1.Text;
person.AppendChild(name);
XmlNode age = xdoc1.CreateElement("age");
age.InnerText = numericUpDown1.Value.ToString();
person.AppendChild(age);
XmlNode email= xdoc1.CreateElement("email");
email.InnerText = textBox3.Text;
person.AppendChild(email);
xdoc1.DocumentElement.AppendChild(person);
xdoc1.Save("C:\\Users\\Nirav\\Desktop\\people1.xml");
}
}
}
////////////////// OUTPUT ////////////////////////



it make chanch like :



--
/\/ir@\/ <(.'.)>
- now double click on button and write code like :
///////////////////////// CODE ////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Forms;
namespace Xml_File_Operation
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
XmlDocument xdoc1 = new XmlDocument();
xdoc1.Load("C:\\Users\\Nirav\\Desktop\\people1.xml");
XmlNode person = xdoc1.CreateElement("person");
XmlNode name = xdoc1.CreateElement("name");
name.InnerText = textBox1.Text;
person.AppendChild(name);
XmlNode age = xdoc1.CreateElement("age");
age.InnerText = numericUpDown1.Value.ToString();
person.AppendChild(age);
XmlNode email= xdoc1.CreateElement("email");
email.InnerText = textBox3.Text;
person.AppendChild(email);
xdoc1.DocumentElement.AppendChild(person);
xdoc1.Save("C:\\Users\\Nirav\\Desktop\\people1.xml");
}
}
}
////////////////// OUTPUT ////////////////////////
it make chanch like :
--
/\/ir@\/ <(.'.)>
Nice Block It is very helpful.... Thanks a lot for your help...
ReplyDeleteYour blog is loaded with informative post on .Net technology. Thanks for sharing. DOT NET Course in Chennai
ReplyDeletevery helpful thanks for sharing... :)
ReplyDeletei created a page to add nodes and saving on sql server in one button.But the nodes and added lokk like this ...(nodes are added at straight)..why?
ReplyDeleteplese sugggest any solutions?
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteI have a problem. Visual Studio showed me this : "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Xml.dll
ReplyDeleteAdditional information: Cannot find file'C:\Users\Administrator\Desktop\test.xml'.
Hello,
DeleteFirst you have to make XML file and then save it to desktop with test.xml name and then run program
very nice information
ReplyDeletebe projects in chennai
2016 ieee java projects in chennai
ieee projects in chennai
very nice information.
ReplyDeleteperl training in chennai
very helpful thanks for sharing... :)
ReplyDeleteinformatica training in chennai
:p nice.
ReplyDeletevery nice and informative blog
ReplyDeletesecure computing projects chennai
very nice and informative blog
ReplyDeletebig data projects chennai
mobile computing projects chennai
cloud computing projects chennai
secure computing projects chennai
This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeleteAndroid Training in Chennai
Ios Training in Chennai
This article is very much helpful and I hope this will be a useful information for the needed one. Keep on updating these kinds of informative things...
ReplyDeleteSelenium Training in Chennai
ReplyDeleteIt is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
Android Training in Chennai
Ios Training in Chennai
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info.
ReplyDeleteHadoop Training in Chennai
Big Data Training in Chennai
Python Training in Chennai
Python Training Centers in Chennai
Data Science Training in Chennai
Data Science Course in Chennai
Data Analytics Training in Chennai
Best AngularJS Training in Chennai
AngularJS Training in Chennai
QlikView Training in Chennai
Informatica Training in Chennai
ReplyDeleteI wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done.
Advanced Selenium Training in Chennai
Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
ReplyDeleteBest Java Training Institute Chennai
Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition
ReplyDeleteBest RPA Training in Bangalore
Best RPA Training in Chennai
Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
ReplyDeletegoogle-cloud-platform-training-in-chennai
Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.
ReplyDeleteBest Java Training Institute Chennai
Java Training Institute Bangalore
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteBest RPA Training in Chennai
Best RPA Training in Bangalore
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
ReplyDeleteamazon-web-services-training-in-bangalore
Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
ReplyDeleteBest Java Training Institute Chennai
Amazon Web Services Training in Chennai
This comment has been removed by the author.
ReplyDeleteAppreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
ReplyDeleteBest selenium training Institute in chennai
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteBest Java Training Institute Chennai
Amazon Web Services Training in Chennai
Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
ReplyDeleteRPA Training in Bangalore
Ciitnoida provides Core and java training institute in
ReplyDeletenoida. We have a team of experienced Java professionals who help our students learn Java with the help of Live Base Projects. The object-
oriented, java training in noida , class-based build
of Java has made it one of most popular programming languages and the demand of professionals with certification in Advance Java training is at an
all-time high not just in India but foreign countries too.
By helping our students understand the fundamentals and Advance concepts of Java, we prepare them for a successful programming career. With over 13
years of sound experience, we have successfully trained hundreds of students in Noida and have been able to turn ourselves into an institute for best
Java training in Noida.
java training institute in noida
java training in noida
best java training institute in noida
java coaching in noida
java institute in noida
Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best...
ReplyDeleteEmbedded training in chennai | Embedded training centre in chennai | Embedded system training in chennai | PLC Training institute in chennai | IEEE final year projects in chennai | VLSI training institute in chennai
Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.
ReplyDeletedatascience training in chennai
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteBest selenium training Institute in chennai
This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeleteEmbedded training in chennai | Embedded training centre in chennai | Embedded system training in chennai | PLC Training institute in chennai | IEEE final year projects in chennai | VLSI training institute in chennai
Thank you Admin! This blog is very useful!
ReplyDeleteBe project center in chennai | Me project center in chennai
Excellent Article!
ReplyDeleteThanks for sharing that wonderful useful information,given contecn was very excellent and easily observe all provided information.
Final Year Bsc Projects Chennai | Final Year BTech Projects in Chennai.