xml序列号错误((XmlHelper.Deserialize))
提示:
XML 文档(1, 2)中有错误。{"不应有 <entryOrder xmlns=''>。"}
原因:
1.缺少根目录(<root>)
2.xml字段转换失败(string->int)
------------------------------------------------------------------------------
代码:
----------------------
var xmlData = row["BizData"].ToString();
Model.QiMen.ThOrderConfirm.request request = XmlHelper.Deserialize(typeof(Model.QiMen.ThOrderConfirm.request), xmlData) as Model.QiMen.ThOrderConfirm.request;
----------------------
public static object Deserialize(Type type, string xml)
{
try
{
using (StringReader sr = new StringReader(xml))
{
XmlSerializer xmldes = new XmlSerializer(type);
return xmldes.Deserialize(sr);
}
}
catch (Exception e)
{
return null;
}
}