我已经尝试了所有无法反序列化此 XML 文档的方法。
<items>
<item>
<id>00175565</id>
<descr>KJAAM-EMC 16x(2+1)x0,5 T500</descr>
<unit>st</unit>
<vat>25</vat>
<inprice>374</inprice>
<isstock>0</isstock>
<stock>0</stock>
<paccount/>
<ean>00175565</ean>
<type>1</type>
<producer/>
<producer_itemno>00175565</producer_itemno>
<package_height/>
<package_depth/>
<package_width/>
<package_weight/>
<stock_place/>
<stock_warning/>
<note/>
<bulky>0</bulky>
<omit>0</omit>
<available>0</available>
<account>3041</account>
<constracct>3231</constracct>
<exportacct>3315</exportacct>
<eurevacct>3318</eurevacct>
<euvatacct>3316</euvatacct>
<supplierno/>
<show_in_webshop>0</show_in_webshop>
<price>
<list-a>
<from-0>486.2</from-0>
</list-a>
</price>
</item>
</items>
这就是我反序列化它的方式
[Serializable()]
public class item
{
[System.Xml.Serialization.XmlElement("id")]
public string ID { get; set; }
[System.Xml.Serialization.XmlElement("descr")]
public string Descr { get; set; }
[System.Xml.Serialization.XmlElement("unit")]
public string Unit { get; set; }
[System.Xml.Serialization.XmlElement("vat")]
public string Vat { get; set; }
[System.Xml.Serialization.XmlElement("inprice")]
public string Inprice { get; set; }
[System.Xml.Serialization.XmlElement("isstock")]
public string Isstock { get; set; }
[System.Xml.Serialization.XmlElement("stock")]
public string Stock { get; set; }
[System.Xml.Serialization.XmlElement("paccount")]
public string Paccount { get; set; }
[System.Xml.Serialization.XmlElement("ean")]
public string Ean { get; set; }
[System.Xml.Serialization.XmlElement("type")]
public string Type { get; set; }
[System.Xml.Serialization.XmlElement("producer")]
public string Producer { get; set; }
[System.Xml.Serialization.XmlElement("producer_itemno")]
public string Producer_itemno { get; set; }
[System.Xml.Serialization.XmlElement("package_height")]
public string Package_height { get; set; }
[System.Xml.Serialization.XmlElement("package_depth")]
public string Package_depth { get; set; }
[System.Xml.Serialization.XmlElement("package_width")]
public string Package_width { get; set; }
[System.Xml.Serialization.XmlElement("package_weight")]
public string Package_weight { get; set; }
[System.Xml.Serialization.XmlElement("stock_place")]
public string Stock_place { get; set; }
[System.Xml.Serialization.XmlElement("stock_warning")]
public string Stock_warning { get; set; }
[System.Xml.Serialization.XmlElement("note")]
public string Note { get; set; }
[System.Xml.Serialization.XmlElement("bulky")]
public string Bulky { get; set; }
[System.Xml.Serialization.XmlElement("omit")]
public string Omit { get; set; }
[System.Xml.Serialization.XmlElement("available")]
public string Available { get; set; }
[System.Xml.Serialization.XmlElement("account")]
public string Account { get; set; }
[System.Xml.Serialization.XmlElement("constracct")]
public string Constracct { get; set; }
[System.Xml.Serialization.XmlElement("exportacct")]
public string Exportacct { get; set; }
[System.Xml.Serialization.XmlElement("eurevacct")]
public string Eurevacct { get; set; }
[System.Xml.Serialization.XmlElement("euvatacct")]
public string Euvatacct { get; set; }
[System.Xml.Serialization.XmlElement("supplierno")]
public string Supplierno { get; set; }
[System.Xml.Serialization.XmlElement("show_in_webshop")]
public string Show_in_webshop { get; set; }
[XmlArray("price")]
[XmlArrayItem("list-a")]
public List<string> price { get; set; }
}
[XmlRoot("items")]
public class items
{
[XmlElement("item")]
public item[] item { get; set; }
}
问题是我得到了第一组项目的一行。但是当我删除
[XmlArray("price")]
[XmlArrayItem("list-a")]
public List<string> price { get; set; }
它给了我所有的行。我已经尝试了很多东西,并查看了其他一些与此相同的已发布问题,但我无法让它发挥作用。
我从中得到一些东西的唯一方法是使用上面的代码。
我非常感谢我能得到的所有帮助!