public static string SerializeXML(object obj) { StringWriter sw = new StringWriter(); XmlSerializer xs = new XmlSerializer(obj.GetType()); xs.Serialize(sw, obj); return(Util_Encoding.ToUnicode(sw.ToString())); }
public static T DeserializeXML <T>(string data) { try { data = Util_Encoding.ToGB2312(data); StringReader sr = new StringReader(data); XmlSerializer xs = new XmlSerializer(typeof(T)); return((T)xs.Deserialize(sr)); } catch { return(default(T)); } }