[XmlRootAttribute("Order",IsNullable = false)]
public class Order
{
[XmlAttribute("pay_method")]
public string paymethod { get; set; }
[XmlAttribute("name")]
public string custid { get; set; }
[XmlArray("")]
[XmlArrayItem("Cargo", IsNullable = false)]
public Cargo[] Cargos { get; set; }
[XmlArray("")]
[XmlArrayItem("AddedService", IsNullable = false)]
public AddedService[] AddedServices { get; set; }
}
XmlSerializer xs = new XmlSerializer();
var requeststring = xs.Serialize(request);
When I run this function, in the result I always get <Cargos> like this:
<Order pay_method="" custid="">
<Cargos>
<Cargo name=""/>
<Cargo name=""/>
</Cargos>
<AddedServices>
<AddedService name=""/>
<AddedService name=""/>
</AddedServices>
</Order>
I just want to get the result without <Cargos></Cargos></AddedServices><AddedServices>, and for example:
<Order pay_method="" custid="">
<Cargo name=""/>
<Cargo name=""/>
<AddedService name=""/>
<AddedService name=""/>
</Order>
How can I config with both:
public Cargo[] Cargos { get; set; }
public AddedService[] AddedServices { get; set; }
Cargoitems but a Collection of them, namedCargos- the current result is the exact representation of your objectAis a collection, like this:public class A: List<Cargo>- however, this would be aListinstead of an array