0
我已經通過xsd.exe工具生成了一個類。將數據插入到生成的類的元素中
下面是模式的相關部分:
<xs:element minOccurs="0" name="propertyLine">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="value">
<xs:complexType mixed="true">
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
該類一代後XSD我得到「propertyLine」數組類型:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class MainSubMessageInfoValue {
private string nameField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
}
所以我設置的數據名稱通過屬性:
propertyLine[0].name = "data";
但現在我想數據集分成元素"value"
(具有「name」屬性的那個)。
我想實現的是:
<value name="data">Bla Bla Bla</value>
我怎樣才能通過代碼做到這一點?如何將「Bla Bla Bla」設置爲「價值」?