Class to XML
Parse Class to XML
Source
public static string ToXml<T>(this T value) where T : class
{
try
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
using (StringWriter stringWriter = new StringWriter())
{
xmlSerializer.Serialize(stringWriter, value);
return stringWriter.ToString();
}
}
catch (Exception)
{
}
return null;
}
Example
none