Validate XML as it Loads into the DOM
If you want to validate the XML against a DTD or schema while it is loading, you need to pass an XmlValidatingReader to the Load method. The ValidationType property of the XmlValidatingReader needs to have been previously set to one of the values in the ValidationType Enumeration excluding the value ValidationType.None, and you need to provide a validationEventHandler. In doing this, Load notifies you of validation errors found during the load process. Unless the ValidationEventHandler stops the load process, the document is loaded into memory even if errors are found. For more information on the XmlValidatingReader, see Validation of XML with XmlValidatingReader.