Breaking News
Loading...
Monday, 10 December 2012

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@\/  <(.'.)>

46 comments:

  1. Nice Block It is very helpful.... Thanks a lot for your help...

    ReplyDelete
  2. Your blog is loaded with informative post on .Net technology. Thanks for sharing. DOT NET Course in Chennai

    ReplyDelete
  3. very helpful thanks for sharing... :)

    ReplyDelete
  4. i 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?
    plese sugggest any solutions?

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete
  10. This comment has been removed by a blog administrator.

    ReplyDelete
  11. This comment has been removed by a blog administrator.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. This comment has been removed by a blog administrator.

    ReplyDelete
  14. This comment has been removed by a blog administrator.

    ReplyDelete
  15. I have a problem. Visual Studio showed me this : "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Xml.dll

    Additional information: Cannot find file'C:\Users\Administrator\Desktop\test.xml'.

    ReplyDelete
    Replies
    1. Hello,
      First you have to make XML file and then save it to desktop with test.xml name and then run program

      Delete
  16. This is excellent information. It 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

    ReplyDelete
  17. 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...
    Selenium Training in Chennai

    ReplyDelete

  18. It 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

    ReplyDelete

  19. I 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

    ReplyDelete
  20. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.

    Best Java Training Institute Chennai

    ReplyDelete
  21. 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
    Best RPA Training in Bangalore


    Best RPA Training in Chennai

    ReplyDelete
  22. 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.
    google-cloud-platform-training-in-chennai


    ReplyDelete
  23. 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.
    Best Java Training Institute Chennai
    Java Training Institute Bangalore

    ReplyDelete
  24. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    Best RPA Training in Chennai
    Best RPA Training in Bangalore

    ReplyDelete
  25. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
    amazon-web-services-training-in-bangalore

    ReplyDelete
  26. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.


    Best Java Training Institute Chennai

    Amazon Web Services Training in Chennai


    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
    Best selenium training Institute in chennai

    ReplyDelete
  29. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    Best Java Training Institute Chennai


    Amazon Web Services Training in Chennai


    ReplyDelete
  30. 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.

    RPA Training in Bangalore

    ReplyDelete
  31. Ciitnoida provides Core and java training institute in

    noida
    . 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

    ReplyDelete
  32. 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.
    datascience training in chennai

    ReplyDelete
  33. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    Best selenium training Institute in chennai

    ReplyDelete
  34. Excellent Article!
    Thanks 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.

    ReplyDelete
  35. Your new valuable key points imply much a person like me and extremely more to my office workers. With thanks; from every one of us.
    AWS Online Training

    ReplyDelete

Thanks for comment

 
Toggle Footer