Tag Archives: XML

Schema Validation Errors While Setting an XML Node Value

When attempting to set the node value in an InfoPath form with code, “schema validation” errors may appear.   This is primarily caused by attempting to set the value of a field with one of the following data types:

  • Whole Number (integer)
  • Decimal (double)
  • Date (date)
  • Time (time)
  • Date and Time (dateTime)

The workaround is to remove the “nil” attribute from the element:

public void DeleteNil(XPathNavigator node)
{
if (node.MoveToAttribute(“nil”, “http://www.w3.org/2001/XMLSchema-instance”))
      node.DeleteSelf();
}

Additional Resources: