How to get IXmlSerialize to not output element tag for null custom object
Posted on 2008-11-07
I have a custom object that is serialized by overriding the WriteXml function as below.
public void WriteXml(XmlWriter writer)
if ( !myObject.bHasValuel ) return;
write.WriteString( myObject.ToString );
However, this causes the output to contain an empty tag
What I need is to NOT have any tag output at all. The element is defined as IsNullable="true", but myObject is never null, but needs to be treated as null for output. How do I do this.