I’m using XmlSerializer to deserialize Xml achives. But I found the class xsd.exe generated only offers capability to read the xml, but no validation. For example, if one node is missing in a document, the attribute field of the generated class will be null, rather than throws a validation exception as I expected. How can I achieve that? Thanks!
I’m using XmlSerializer to deserialize Xml achives. But I found the class xsd.exe generated
Share
The following code should validate against a schema while deserializing. Similar code can be used to validate against a schema while serializing.