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;
}
}
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