【发布时间】:2011-09-11 00:17:48
【问题描述】:
是否可以有一个 XML,其中一个元素具有混合内容,并将混合元素中的文本反序列化为自定义对象而不是 string?
我试过了:
[XmlText(typeof(textType))]
[XmlElement("query", typeof(templateBodyQuery))]
[XmlElement("expand", typeof(expandType))]
[XmlElement("insert", typeof(expandTypeInsert))]
public object[] Items { get; set; }
预计文本项将被序列化为 textType,但我收到 'textType' cannot be used as 'xml text' 错误。
这是我的textType 班级:
public class textType
{
[XmlText]
public string Value { get; set; }
}
【问题讨论】:
标签: c# xml-serialization