【发布时间】:2014-02-07 12:01:58
【问题描述】:
除列表之外的所有反序列化工作:
(resdes 是一个列表)
public class SearchResponse
{
// ELEMENTS
[XmlElement("ResDes")]
public ResDes resdes { get; set; }
[XmlElement("Return")]
public Return returns { get; set; }
// CONSTRUCTOR
public SearchResponse()
{}
}
这行得通:
<Return>
<test>0010000725</test>
</Return>
public class Return
{
// ELEMENTS
[XmlElement("test")]
public Test test{ get; set; }
}
但项目列表不起作用,它会变为 null
<ResDes >
<item>
<PoBox />
<City1>South Korea</City1>
<Country>SK</Country>
</item>
</ResDes >
public class ResDes
{
// ELEMENTS
[XmlArrayItem("item")]
public List<ResDesItem> ResDesItem { get; set; }
// CONSTRUCTOR
public ResDes ()
{ }
}
Resdesitem 类:
[DataContract()]
public class ResDesItem
{
[XmlElement("PoBox")]
public PoBox PoBox { get; set; }
[XmlElement("City1")]
public City1 City1 { get; set; }
[XmlElement("Country")]
public EtResultDetAdritemCountry EtResultDetAdritemCountry { get; set; }
// CONSTRUCTOR
public ResDesItem()
{ }
}
【问题讨论】:
-
您是否尝试使用
[Serializable]属性标记 ResDesItem 类? -
嗨,我目前正在为手机平台开发,所以我使用了它的等价物[DataContract()],但它仍然是空的
-
ResDesItem类在哪里?你能粘贴那个类吗?
标签: c# xml deserialization poco