topical media & game development
professional-xml-15-Listing-15-14.txt / txt
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
namespace XmlProject
{
class Program
{
static void Main(string[] args)
{
try
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.CheckCharacters = true;
settings.Encoding = Encoding.Unicode;
settings.Indent = true;
XmlWriter xw = XmlWriter.Create("C:/MyXml.xml", settings);
xw.WriteStartDocument();
xw.WriteStartElement("StockOrder");
xw.WriteStartElement("Symbol");
xw.WriteValue("MSFT");
xw.WriteEndElement(); // Symbol
xw.WriteStartElement("Quantity");
xw.WriteValue(100);
xw.WriteEndElement(); // Quantity
xw.WriteStartElement("OrderTime");
xw.WriteValue(DateTime.Now.ToUniversalTime());
xw.WriteEndElement(); // OrderTime
xw.WriteEndElement(); // StockOrder
xw.WriteEndDocument();
xw.Close();
Console.Write("Written to disk");
Console.ReadLine();
}
catch (System.Exception ex)
{
Console.Error.WriteLine(ex.ToString());
Console.ReadLine();
}
}
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.