avatar
Linq to xml

Guest 94 9th Dec, 2019

                                           
                         using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace linqxmlexam
{
    class Program
    {
        static void Main(string[] args)
        {
            XNamespace empnm = "urn:lst-emp:emp";
            XDocument xdoc = new XDocument(new XDeclaration("1.0","UTF-16",null),
                new XElement("employees",
                    new XComment("comment"),
                    new XElement("Empid","5"),
                    new XElement("name","vimal"),
                    new XElement("sex","male")));
            StringWriter sw =new StringWriter();
            XmlWriter xwrite =XmlWriter.Create(sw);
            xdoc.Save(xwrite);
            xwrite.Close();
            xdoc.Save(@"D:\xml\vimal1.xml");
            Console.WriteLine("saved");
            Console.ReadLine();

        }
    }
}
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes