XML TO Class
Parse XML String to Class
Source
public static T ParseToClass<T>(this string xml) where T : class
{
try
{
if (!string.IsNullOrEmpty(xml) && !string.IsNullOrWhiteSpace(xml))
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
using (StringReader stringReader = new StringReader(xml))
{
return (T)xmlSerializer.Deserialize(stringReader);
}
}
}
catch (Exception)
{
}
return null;
}
Example
None