【发布时间】:2019-12-30 10:44:38
【问题描述】:
我有一个xsd.exe 输出 c# 类:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class OrdinateZacrep
{
private decimal xField;
private decimal yField;
/// <remarks/>
public decimal x
{
get
{
return this.xField;
}
set
{
this.xField = value;
}
}
/// <remarks/>
public decimal y
{
get
{
return this.yField;
}
set
{
this.yField = value;
}
}
}
XML 很简单:
<ordinate>
<x>587865.52</x>
<y>1397457.84</y>
</ordinate>
但有时 XML 看起来像:
<ordinate>
<x>587865.52</x>
<_y>1397457.84</_y>
</ordinate>
我怎样才能用单课阅读这个简单的东西?
这里是 xsd 切片:
<xsd:complexType name="OrdinateOut">
<xsd:annotation>
<xsd:documentation>Parcel coordinates</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="x" type="xsd:decimal">
<xsd:annotation>
<xsd:documentation>Ordinate X</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="y" type="xsd:decimal">
<xsd:annotation>
<xsd:documentation>Ordinate Y</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
【问题讨论】:
-
什么会在 xml 文件中产生
_y元素?你能给我们看看你的 xsd 文件吗? -
@Samuel
_y对于 xsd 架构无效。但是这里有太多带有_y的xml文档,我不能忽略它。 -
不熟悉 C# 代码,这个问题是关于更改自动生成 XSD 的 C# 代码,还是关于更改 XSD 以使您显示的两个 XML 文档都有效?