Knowledge Management Banner

Knowledge Management Banner

Xml string to object

//required libraries
using System.Xml.Serialization;
using System.IO;    

public static T XMLStringToObject<T>(string XmlData) where T : class
{
    var serializerXml = new XmlSerializer(typeof(T));

    using (var sr = new StringReader(XmlData))
    {
        var sp = serializerXml.Deserialize(sr) as T;
        return sp;
    }
}

No comments

Powered by Blogger.