using System;
using System.IO;
using System.Xml;
using System.Text;
public class Sample {
public static void Main() {
Double price = 9.95;
DateTime date = new DateTime(2010, 5, 20);
using (XmlWriter writer = XmlWriter.Create("data.xml"))
{
writer.WriteStartElement("book");
writer.WriteStartAttribute("pub-date");
writer.WriteValue(date);
writer.WriteEndAttribute();
writer.WriteStartElement("price");
writer.WriteValue(price);
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
}
}
}