XML object from a string of the form. - CSharp System.Xml.Serialization

CSharp examples for System.Xml.Serialization:XmlSerializer

Description

XML object from a string of the form.

Demo Code


using System.Xml.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System.IO;//from   ww w  . j  a v  a  2  s .  c o m
using System.Globalization;
using System.Collections.Generic;
using System;

public class Main{
        /// <summary>
        /// XML object from a string of the form.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="inXmlText"></param>
        /// <returns></returns>
        public static T FromXml<T>(String inXmlText)
        {
            var serializer = new XmlSerializer(typeof(T));
            return (T)serializer.Deserialize(new StringReader(inXmlText));
        }
}

Related Tutorials