I'm trying to serialize a XML file to an object, when deleting a XML tag, I'm expecting an exception because my XML file is not valid any more, but I still get my data object with deleted tag (property) is null. How to make this specific tag required so when trying to serialize it, it will throw an exception saying tag xxx is missing => XML file is not valid => so data object is also null.
My XSD
...
<xs:element name="Language" minOccurs="1" maxOccurs="1">
...
My XML
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<item>
<sub1>1037</sub1>
<Language>F</Language><!-- If I delete this tag, my XML file should be invalid -->
<sub1>ZDC</sub1>
</item>
<root>
My serialize boject
...
/// <remarks/>
public string Language
{
get
{
return this.languageField;
}
set
{
this.languageField = value;
}
}
...