This is really starting to wind me up. I've tried searching all over the net with this but it seems people only want to consume XML files, not build them :S. I'm building an XML file which needs to be compliant with an .xsd referencing the http://www.w3.org/2001/XMLSchema
namespace.
One of the elements in the XSD is a datetime which unfortunately may or may not have a value.
From what I've read, the correct way to achieve this is to use the nil
attribute, but no matter what I do, the validation just moans at me, saying that
'' is not a valid value for type 'date'
I've tried:
elementName.SetAttributeValue(xmlNamespace + "nil", "true"); //(xmlNamespace = pre-declared NS)
and
elementName.SetAttributeValue("nil", "true");
Alongside everything else I can think of, but I just can't get it to validate.
Unfortunately I also can't just leave it out as the element doesn't have minOccurs = 0
in the XSD either.
Any ideas?