Home / ASP.NET Wiki / HTML / Web Controls / XML / System.XML namespace

System.XML namespace

 Rate It (0)

XML namepace has XmlWriter class to write to XML file.

 Code in C#:

using System.XML; //Add this namespace to use XmlWriter and XmlReader classes

StringBuilder sb = new StringBuilder();

XmlWriter xwrite = XmlWriter.Create("c:\\sample.xml"); // here you can provide the path for the xml file.

//If you want to write to a string instead of file.Replace the above line with the following line.

//XmlWriter xwrite = XmlWriter.Create(sb);

writer.WriteStartDocument(true);

 

writer.WriteStartElement(
"USERNAME");writer.WriteString("Admin");

writer.WriteEndElement();

 

 

 

writer.WriteEndDocument();

writer.Flush();

writer.Close();

 

Revision number 1, Wednesday, May 27, 2009 12:29:26 AM by roopeshreddy

Comments

Shortcuts

Table of Contents

Top Wiki Contributors

(last 30 days)

  1. abiruban (1)