我有一个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>
但是,somtimes XML看起来像:
<ordinate>
<x>587865.52</x>
<_y>1397457.84</_y>
</ordinate>
我如何在单节课上读这个简单的东西?
这是xsd slice:
<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>
您正在使用私有变量xField和yField。因此,只需创建一个新属性即可将其保存到xField和yField中
public decimal _y
{
get
{
return this.yField;
}
set
{
this.yField = value;
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句