topical media & game development

talk show tell print

professional-xml-15-Listing-15-6.txt / txt



  using System;
  using System.Collections.Generic;
  using System.Text;
  using System.Xml.Serialization;
  
  namespace XmlSerializationProject
  {
      class Program
      {
          static void Main(string[] args)
          {
              try
              {
                  XmlSerializer classSerialization =
                      new XmlSerializer(typeof(StockOrder));
  
                  XmlSerializerNamespaces serName =
                      new XmlSerializerNamespaces();
  
                  serName.Add("reu", "http://www.reuters.com/ns/");
                  serName.Add("lip", "http://www.lipperweb.com/ns/");
  
                  StockOrder so = new StockOrder();
                  so.Symbol = "MSFT";
                  so.Quantity = 100;
                  
                  classSerialization.Serialize(Console.Out, so, serName);
                  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.