How to create new xml file in C#,Net

First make form 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 button2_Click(object sender, EventArgs e)
        {
            XmlTextWriter xmlwrt = new XmlTextWriter("C:\\Users\\Nirav\\Desktop\\people1.xml", Encoding.UTF8);
            xmlwrt.Formatting = Formatting.Indented;
            xmlwrt.WriteStartElement("people");
            xmlwrt.WriteStartElement("person");

            xmlwrt.WriteStartElement("name");
            xmlwrt.WriteString(textBox1.Text);
            xmlwrt.WriteEndElement();

            xmlwrt.WriteStartElement("age");
            xmlwrt.WriteString(numericUpDown1.Value.ToString());
            xmlwrt.WriteEndElement();

            xmlwrt.WriteStartElement("email");
            xmlwrt.WriteString(textBox3.Text);
            xmlwrt.WriteEndElement();

            xmlwrt.WriteEndElement();
            xmlwrt.WriteEndElement();

            xmlwrt.Close();

        }


///////////////////////      OUTPUT   /////////////////////////





--  Now click on button this will create file on desktop like .............




--
/\/ir@\/  <(.'.)>

Comments

Popular posts from this blog

How to make and use web service in Microsoft Dynamics Navision.

How to use Format function in Microsoft Dynamics Navision.

How to create simple report in Microsoft Dynamics Navision.