Mega Code Archive

 
Categories / C# Tutorial / XML
 

Append to xml file

using System; using System.IO; using System.Xml;  public class Test{    public static void Main(string[] args){     StreamWriter sw = File.AppendText("logfile-entries.txt");     XmlTextWriter xtw =  new XmlTextWriter(sw);      xtw.WriteStartElement("event");      xtw.WriteElementString("ip", "192.168.0.1");     xtw.WriteElementString("http_method", "POST");     xtw.WriteElementString("file", "comments.aspx");     xtw.WriteElementString("date", "1999-05-05T19:25:13.238220-08:00");         xtw.Close();                     } }