I have the following XML:
<Line id="6">
<item type="product" />
<warehouse />
<quantity type="ordered" />
<comment type="di">Payment by credit card already received</comment>
</Line>
Is there a way to not output the elements that aren't set when serializing an object in .NET (2010 with C#)? In my case, the item type
, the warehouse
, the quantity
so that I end up with the following instead when serialized:
<Line id="6">
<comment type="di">Payment by credit card already received</comment>
</Line>
I can't see any properties in the XmlElement or XmlAttribute that would let me achieve this.
Is XSD required? If it is, how would I go about it?