示例#1
0
        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()));
        }
示例#2
0
 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));
     }
 }