0
我有一個看起來像這樣的XML:如何序列與陣列複雜的對象
<SOAPRequestItemHeadReturn xmlns:ns2="fsw" xsi:type="ns2:SOAPItemRevisionHeadResult">
<comment xsi:type="xsd:string" xsi:nil="true"/>
<searchComplete xsi:type="xsd:boolean">true</searchComplete>
<resultList xsi:type="ns2:SOAPItemRevisionHead">
<stringKey xsi:type="xsd:string">ItemRevision.ItemID</stringKey>
<stringValue xsi:type="xsd:string">cam_english_template</stringValue>
</resultList>
<resultList xsi:type="ns2:SOAPItemRevisionHead">
<stringKey xsi:type="xsd:string">ItemRevision.ItemID</stringKey>
<stringValue xsi:type="xsd:string">cam_english_template</stringValue>
</resultList>
<search xsi:type="ns2:SearchType">
<value xsi:type="xsd:string">ItemRevision.ItemID</stringKey>
<used xsi:type="xsd:boolean">true</searchComplete>
</search>
...
基本上SOAPRequestItemHeadReturn的結構如下:
ItemHeadReturn
|-comment
|-searchComplete
|-resultList
|-resultList
|-resultList
|-search
|-search
|-search
的問題是:我如何建立類SOAPRequestItemHeadReturn
?這裏是一個可能的結構:
public class SOAPItemRevisionHeadResult{
public string comment { get; set;}
public bool searchComplete { get; set;}
public SearchType[] search { get; set;}
public StringMap[] resultList {get; set;}
}
而且我需要填寫的屬性,但我不知道什麼屬性和位置。有任何想法嗎?
不得不編輯xml一點,但它的工作,謝謝。我期待使用xmlArrayAttibute和XmlArrayElementAttribute,爲什麼xsd沒有使用它們? –
它不使用這些屬性,因爲它們不是強制性的。默認行爲足以根據需要運行序列化。 –