【发布时间】:2015-05-11 07:30:32
【问题描述】:
我有带有商店列表的 xml。每个商店都有和节点。在其中一些是浮动的,在一些是空节点。所以它看起来像这样:
<shops>
<shop>
<lat>123.123</lat>
<lon>123.123</lon>
</shop>
<shop>
<lat null="true"/>
<lon null="true"/>
</shop>
</shops>
我的反序列化这个xml的类是这样的
[XmlRoot("shops")]
public class ShopList
{
[XmlElement("shop")]
public Shop[] ShopArray { get; set; }
public class Shop
{
[XmlElement("lat", IsNullable = true)]
public float? Latitude { get; set; }
[XmlElement(ElementName="lon", IsNullable=true)]
public float? Longitude { get; set; }
}
}
但是当我反序列化 xml 时出现错误。你有什么线索吗?
【问题讨论】:
-
您好,欢迎来到 SO。能否请您更具体一点。错误是什么?
标签: c# xml-serialization