If you’re performing data migration, and moving XML nodes around (or generating the form from template.xml or something similar), it will leave xsi:nil=”true” attributes on the nodes.
Then, if you copy these nodes and intend on filling them with information, you need to either remove the xsi:nil attributes, or set them to false. How do you do it? It’s quite simple:
XPathNavigator nilField = DOM.SelectSingleNode(“/my:myFields/my:myNilField“);
if (nilField.MoveToAttribute(“nil”, “http://www.w3.org/2001/XMLSchema-instance”))
nilField.DeleteSelf();
This essentially selects the field in question, positions the XPathNavigator to point at the nil attribute, and if it exists (or the pointer move succeeds) it will remove the attribute at its current position (aka, itll delete the nil attribute).
This tends to happen with DateTime fields in your schema (more often than not).
Matt