当我用xsd.exe
最少的元数据为给定的 XML 生成 C# 类时,它是否识别数字属性(和 InnerTextes)并将它们映射到数字类型的属性(即:int、double)?
问问题
82 次
1 回答
0
快速测试:
<test>
<i>123</i>
<f>12.3</f>
<s>abc</s>
</test>
然后:
xsd test.xml
xsd test.xsd /c
给出:
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:element name="i" type="xs:string" minOccurs="0" />
<xs:element name="f" type="xs:string" minOccurs="0" />
<xs:element name="s" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
和:
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string i {
get {
return this.iField;
}
set {
this.iField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string f {
get {
return this.fField;
}
set {
this.fField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string s {
get {
return this.sField;
}
set {
this.sField = value;
}
}
所以我要投票“不是很可靠,如果有的话”。
于 2010-11-05T11:41:33.507 回答