用XmlSerializer进行xml反序列化的时候,程序报错:
不应有 <xml xmlns=''>。
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: 不应有 <xml xmlns=''>。
我的xml如下:
1 | < xml >< ToUserName > <![CDATA[gh_1874139df55e]]> </ ToUserName > |
2 | < FromUserName > <![CDATA[ov4latyc1pi0_Ics0uHY6QTLRDg8]]> </ FromUserName > |
3 | < CreateTime >1388056811</ CreateTime > |
4 | < MsgType > <![CDATA[text]]> </ MsgType > |
5 | < Content > <![CDATA[哈哈]]> </ Content > |
6 | < MsgId >5961658608245054071</ MsgId > |
要反序列化的对象类型:
01 | public class WXP_Message |
03 | public int MessageId { get ; set ; } |
05 | public string ToUserName { get ; set ; } |
07 | public string FromUserName { get ; set ; } |
09 | public DateTime CreateTime { get ; set ; } |
11 | public string MsgType { get ; set ; } |
13 | public string Event { get ; set ; } |
15 | public string Content { get ; set ; } |
17 | public string PicUrl { get ; set ; } |
19 | public string Format { get ; set ; } |
21 | public string Location_X { get ; set ; } |
23 | public string Location_Y { get ; set ; } |
25 | public string Scale { get ; set ; } |
27 | public string Label { get ; set ; } |
29 | public string Title { get ; set ; } |
31 | public string Description { get ; set ; } |
33 | public string Url { get ; set ; } |
35 | public int MsgId { get ; set ; } |
37 | public int MediaId { get ; set ; } |
39 | public int ThumbMediaId { get ; set ; } |
41 | public bool IsReplied { get ; set ; } |
43 | public string ReplyContent { get ; set ; } |
45 | public DateTime ReplyTime { get ; set ; } |
47 | public bool IsGiftVoucher { get ; set ; } |
49 | public int IntTime { get ; set ; } |