【发布时间】:2016-06-06 20:29:39
【问题描述】:
我的数据如下所示:
<City Code="LON">
<![CDATA[London]]>
</City>
<Item Code="IBI3">
<![CDATA[IBIS EXCEL]]>
</Item>
我有一些看起来像这样的类是自动生成的:
public class City
{
[XmlAttribute(AttributeName = "Code")]
public string Code { get; set; }
[XmlElement(ElementName = "Item" )]
public string Text { get; set; }
}
[XmlRoot(ElementName = "Item")]
public class Item
{
[XmlAttribute(AttributeName = "Code")]
public string Code { get; set; }
[XmlText]
public string Text { get; set; }
}
当我反序列化 xml 字符串时,我得到 Text 的空值....如何反序列化这个 CDATA?
【问题讨论】:
-
我尝试使用 XmlCDataSection 和 XmlCharacterData 作为 Text 属性的类型....无济于事
标签: .net deserialization cdata