Progged programming site

Programming source code, articles, tutorials, links and chat

create an XML file in C#

This example shows how to create an XML file in C#.
using System;
using System.Xml;
namespace ConsoleApplication3
{
class Class1
{
static void Main(string[] args)
{
string filename = @”d:\test.xml”;
XmlTextWriter textwriter = new XmlTextWriter(filename,null);
textwriter.Formatting = Formatting.Indented;
textwriter.WriteStartDocument();
textwriter.WriteStartElement(”links”);
textwriter.WriteStartElement(”category”,”programming”);
textwriter.WriteElementString(”address”,”www.progged.net”);
textwriter.WriteElementString(”description”,”programming site”);
textwriter.WriteEndElement();
textwriter.WriteEndElement();
textwriter.WriteEndDocument();
textwriter.Flush();
textwriter.Close();
}
}
}

Bookmark It

Hide Sites

[ Back to top ]

Sponsors