[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, as a result, I always get <Cargos>
as follows:
<Order pay_method="" custid="">
<Cargos>
<Cargo name=""/>
<Cargo name=""/>
</Cargos>
<AddedServices>
<AddedService name=""/>
<AddedService name=""/>
</AddedServices>
</Order>
I 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 configure both:
public Cargo[] Cargos { get; set; }
public AddedService[] AddedServices { get; set; }
source
share