topical media & game development

talk show tell print

professional-xml-15-Listing-15-11.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
              {
                  FileStream dehydrated = new 
                     FileStream("C:/MyXML.xml", FileMode.Open);
  
                  XmlSerializer serialize = new 
                     XmlSerializer(typeof(MultiStockOrder));
  
                  MultiStockOrder myOrder = new MultiStockOrder();
                  myOrder = (MultiStockOrder) serialize.Deserialize(dehydrated);
  
                  foreach(StockOrder singleOrder in myOrder.StockOrderMultiple) 
                  {
                     Console.WriteLine("{0}, {1}, {2}", 
                        singleOrder.Symbol, 
                        singleOrder.Quantity, 
                        singleOrder.OrderTime.ToShortDateString());
                  }
  
                  dehydrated.Close();
                  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.