topical media & game development
professional-xml-15-Listing-15-12.txt / txt
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace XmlSerializationProject
{
class Program
{
static void Main(string[] args)
{
try
{
XmlSerializer classSerialization =
new XmlSerializer(typeof(StockOrder));
StockOrder so = new StockOrder();
so.Symbol = "MSFT";
so.Quantity = 100;
XmlTextWriter tw = new
XmlTextWriter("C:/MyXml.xml", Encoding.UTF8);
classSerialization.Serialize(tw, so);
tw.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.