The following model class serializes to
[XmlRoot]
public class A
{
[XmlAttribute]
public string Period { get; set; }
public List<C> B { get; set; }
}
<?xml version=1.0>
<A Period="Today">
<B>
<C>
</C>
<C>
</C>
</B>
</A>
Now, I dont want that <B> (List of objects should directly be listed under XmlRoot)
The resulting XML should look like,
<A Period="Today">
<C>
</C>
<C>
</C>
</A>
Any ideas how ?
Set the list as an XML element. This will force the rendering of only its elements:
[XmlRoot]
public class A
{
[XmlAttribute]
public string Period { get; set; }
[XmlElement("C")]
public List<C> B { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With