Deserialize XML to Object - CSharp System.Xml

CSharp examples for System.Xml:XML Serialization

Description

Deserialize XML to Object

Demo Code


using System.Xml.Serialization;
using System.Text;
using System.IO;/*from  w ww .  j  a  v a  2s  . c om*/
using System;

public class Main{
        public static T Deserialize<T>(string xml)
        {
            StringReader textReader = new StringReader(xml);
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            return (T) serializer.Deserialize(textReader);
        }
}

Related Tutorials