【发布时间】:2014-08-04 18:37:02
【问题描述】:
我有以下 XML 代码:
<sees direction="NE"/>
<sees direction="E"/>
<sees direction="SE">
<object>diamond</object>
<background>green</background>
</sees>
<sees direction="SW">
<background>green</background>
</sees>
我对对象标签的反序列化有疑问。首先我手动编写属性,然后我使用 XSD 工具生成类并编辑 XMLElementAttribute。
System.Xml.Serialization.XmlElementAttribute("object", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string @object
{
get
{
return this.objectField;
}
set
{
this.objectField = value;
}
}
即使编译后我也没有找到填充该字段的方法,并且所有其余字段(例如背景)都可以正常工作。
我有什么遗漏的吗?
【问题讨论】:
标签: c# xml serialization keyword