我需要创建一个可以从此 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>
我的问题是Measure,它需要是某种列表,但是当我创建一个列表时,它会错误地序列化
<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; }
}