码迷,mamicode.com
首页 > 其他好文 > 详细

XML序列化及反序列化

时间:2015-08-27 15:10:42      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

//加载xml及反序列化
XmlDocument xdc = new XmlDocument(); xdc.Load(url); XmlSerializer ser = new XmlSerializer(typeof(InModel)); StringReader sr = new StringReader(xdc.InnerXml); InModeldocmodel = ser.Deserialize(sr) as InModel;
//对象序列化xml         
      OutModel outmodel = new OutModel(); XmlSerializer serializer = new XmlSerializer(typeof(OutModel )); MemoryStream ms = new MemoryStream(); serializer.Serialize(ms, outmodel ); return Content(System.Text.Encoding.UTF8.GetString(ms.ToArray()), "text/xml");

  

  

XML序列化及反序列化

标签:

原文地址:http://www.cnblogs.com/lb12081116/p/4763203.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!