Reputation: 24789
I have an XSD from another company which forces me to generate empty tags in the Xml. I've created a class based on this XSD with XSD.exe. One of the properties is a DateTime
property. In my case I don't need this property, so I set it's value to DateTime.MinValue
. This, offcourse, generates a tag with the min value as a value.
What I want is that while serializing a check takes place: if the value equals the min value, then generate an emptye tag, otherwise create the tag with the value.
Does someone know how to accomplish this?
Upvotes: 0
Views: 552
Reputation: 7506
If you have the option of converting this property to string
instead of storing it as a DateTime
object, you can set it to String.Empty
instead of DateTime.MinValue
. The serializer will then create an empty tag.
Again, as far as I know, this only works with strings.
Upvotes: 1