public class ProductAdvertisement
 {
     public TdDate Date;
            
     public Int32 ProductId;
            
     public Int32? QuantityAvailable;
             
     public TdPeriodTime advertisePeriod
            
     public String adPlacement;
 }
             
 internal class ProductAdvertisementWriter
 {
 
     public static void Write()
     {
         // Setup the advertisement
         ProductAdvertisement x = new ProductAdvertisement();
 
         x.Date = new TdDate(DateTime.Today);
         x.ProductId = 100;
         x.QuantityAvailable = 2000;
             
         // Advertisement will last for 7 hours
         x.AdvertisePeriod = new TdPeriodTime(new TdTime(7, 0, 0), new TdTime(14, 0, 0);
         x.adPlacement = "The Newspaper";
            
         // Write out today's advertisements to the file.
         //
         // Open the file.
         XmlWriterSettings settings = new XmlWriterSettings();
         settings.Indent = true;
         XmlWriter writer = XmlWriter.Create(@"C:\Temp\ProductAdvertisements.XML", settings);
         writer.WriteStartElement("ProductAdvertisements");
   
         // Write out the schema.
         XmlSchemas schemas = new XmlSchemas();
         XmlSchemaExporter schExporter = new XmlSchemaExporter(schemas);
         schExporter.ExportTypeMapping(new XmlReflectionImporter().ImportTypeMapping(typeof(ProductAdvertisement)));
         schemas[0].Write(writer);
            
         // Write out the advertisements.
         XmlSerializer xml = new XmlSerializer(typeof(ProductAdvertisement));
         xml.Serialize(writer, x);
 
         // Close the document.
         writer.WriteEndDocument();
         writer.Close();
     }
 }
             
/* Output is:
             
2007-02-01100200007:00:0014:00:00The Newspaper
             
*/