Click here to Skip to main content
12,252,903 members (58,187 online)
Click here to Skip to main content
Articles » Languages » XML » XML/XSLT » Downloads

Stats

24.8K views
389 downloads
29 bookmarked
Posted

Template Messages Using XSL Transformations and XML Serialization

, 23 Aug 2007 CPOL
This article shows how you can implement templated messages, such as email templates
using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace TemplatesExample
{
    [Serializable]
    [XmlRoot("mailData")]
    public class ProductsOrderMailData
    {
        private string mCustomerName;
        private int mOrderId;
        private DateTime mOrderDate;
        private string mFormattedOrderDate;
        private List<Product> mProducts = new List<Product>();

        [XmlElement("name")]
        public string CustomerName
        {
            get { return mCustomerName; }
            set { mCustomerName = value; }
        }

        [XmlAttribute("orderId")]
        public int OrderId
        {
            get { return mOrderId; }
            set { mOrderId = value; }
        }

        [XmlIgnore]
        public DateTime OrderDate
        {
            get { return mOrderDate; }
            set
            {
                mOrderDate = value;
                mFormattedOrderDate = mOrderDate.ToString("dd MMM yyyy HH:mm");
            }
        }

        [XmlElement("orderDate")]
        public string FormattedOrderDate
        {
            get { return mFormattedOrderDate; }
            set { mFormattedOrderDate = value; }
        }

        [XmlArray("orderedProducts")]
        [XmlArrayItem("orderedProduct")]
        public List<Product> Products
        {
            get { return mProducts; }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Cvetomir Todorov
Software Developer
Bulgaria Bulgaria
Cvetomir Todorov is a student in the Sofia University. His interests include Object Oriented Programming and Design, Design Patterns, Producing High-Quality Code, Refactoring, Unit Testing, Test Driven Development etc. The technology he's using is .NET with C# language.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 23 Aug 2007
Article Copyright 2007 by Cvetomir Todorov
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid