0

I have the following model

  [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; }
  }

And I got the following 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>

How should I remove <Items> tag? It looks like the model automatically generates that tag.

user2585578
  • 295
  • 6
  • 18
  • Something like [this](https://blogs.msdn.microsoft.com/youssefm/2009/06/12/customizing-the-xml-for-collections-with-xmlserializer-and-datacontractserializer/)? – Jeroen Heier Sep 08 '16 at 19:00
  • Use [`[XmlElement("Item")]`](https://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlelementattribute.aspx). See [XML Serialization - Disable rendering root element of array](https://stackoverflow.com/questions/2006482/xml-serialization-disable-rendering-root-element-of-array). – dbc Sep 08 '16 at 19:11

0 Answers0