我该如何防止XML序列化模型自动生成标签?

时间:2016-09-08 18:55:56

标签: c# asp.net xml xml-serialization xmlserializer

我有以下型号

  [Serializable]
  [XmlRoot("store-inventory", Namespace = "http://seller.marketplace.sears.com/catalog/v7", IsNullable = true)]
  public class SearsInventoryFormModel {
    public SearsItemInventoryModel[] Items { get; set; }
  }

  [XmlType("item")]
  public class SearsItemInventoryModel {
    // for inventory
    [XmlArray("locations")]
    [XmlArrayItem("location")]
    public List<SearsLocationModel> Locations { get; set; }
    [XmlAttribute("item-id")]
    public string ItemID { get; set; }
  }

我得到了以下xml

<?xml version="1.0" encoding="utf-8"?>
<store-inventory xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://seller.marketplace.sears.com/catalog/v7">
  <Items>
    <item item-id="imps_twob_Black">
      <locations>
        <location location-id="295229030">
          <quantity>4</quantity>
          <low-inventory-threshold xsi:nil="true" />
          <pick-up-now-eligible>false</pick-up-now-eligible>
          <inventory-timestamp>2016-09-08T14:47:34.88605-04:00</inventory-timestamp>
        </location>
      </locations>
    </item>
  </Items>
</store-inventory>

如何删除<Items>代码?看起来模型会自动生成该标签。

0 个答案:

没有答案