//对象序列化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;