XML序列化及反序列化

//对象序列化xml 
        OutModel outmodel = new OutModel();
XmlSerializer serializer = new XmlSerializer(typeof(OutModel));
using(MemoryStream ms = new MemoryStream())
        {
    serializer.Serialize(ms, outmodel);
           return Content(System.Text.Encoding.UTF8.GetString(ms.ToArray()), "text/xml");
        }
 
//加载XML及反序列化
        XmlDocument xdc = new XmlDocument();
xdc.Load(url);
XmlSerializer ser = new XmlSerializer(typeof(InModel));
StringReader sr = new StringReader(xdc.InnerXml);
InModel docmodel = ser.Deserialize(sr) as InModel;
上一篇:js--敏感词屏蔽


下一篇:Nginx四层负载均衡概述