我需要創建一個可以從這個XML被deserialised反序列化XML
<Item>
<Description>Timber(dry)</Description>
<Measure Type="VOLUME">
<Value>1.779</Value>
<Units>m3</Units>
</Measure>
<Measure Type="WEIGHT">
<Value>925.08</Value>
<Units>Kilogram</Units>
</Measure>
<Measure>
<Value>1</Value>
<Units>Units</Units>
</Measure>
</Item>
我的問題是措施一個對象,它需要某種形式的名單,但是當我創建了一個 列表它串行化錯誤
<Item>
<Description>Timber(dry)</Description>
<Measures> <--- Dont want this <Measures> tag
<Measure Type="VOLUME">
<Value>1.779</Value>
<Units>m3</Units>
</Measure>
<Measure Type="WEIGHT">
<Value>925.08</Value>
<Units>Kilogram</Units>
</Measure>
<Measure>
<Value>1</Value>
<Units>Units</Units>
</Measure>
</Measures> <---
</Item>
這是我迄今爲止
public class Item
{
public Item()
{
this.Measures = new List<Measure>();
}
public string Description { get; set; }
public List<Measure> Measures { get; set; }
}
public class Measure
{
public string Value { get; set; }
public string Units { get; set; }
[System.Xml.Serialization.XmlAttributeAttribute()]
public string Type { get; set; }
}
..並通過錯誤..? –
我已更新該問題。也許它會澄清更多 – Gaven