【发布时间】:2016-10-19 07:16:23
【问题描述】:
我有一个 xml 文件,我尝试为它编写一个类型。 在某个时刻,我的大脑冻结了。
这个xml是我能写的最小的。
<Level ID="SomeID">
<Selection Name="AnotherID">
<Content><![CDATA[SomeData]]></Content>
</Selection>
</Level>
在cs中我想写一个类作为xmlserializer的类型。
public class Level
{
[XmlAttribute]
public string ID {get; set;}
public ??? Selection {get; set;}
//What is the type of CDATA
//Where would the Name Attribute go?
}
不知何故,Selection 必须是一个具有属性的类,而且 Selection 的类型是 CData。无论 CData 是什么,它都是标准类型,因此我无法设置 Name 属性。
如何在 cs 类中解决这个问题? - xml 是旧的,现在无法更改。
【问题讨论】:
标签: c# xml xmlserializer