Validation of xml with xmlvalidatingreader example
You need data validation, for example, when you process incoming data whose origin isn't certified or whose content layout isn't completely predictable (i.e., cases in which the text that users type at runtime determines the XML data layout). NET, you must use the Xml Validating Reader class, which derives from the Xml Text Reader class and works in much the same way.
Unlike the parent class, Xml Validating Reader lets you set the required validation type and the action to take in case of errors.
The Validation Event Handler will call you back if there's any trouble. XSD files - 64 of them - that represent a single specification.
You can poke around in the document if you like, while the validation happens, but when I'm just validating I do a while(reader. I load the most-leaf node to load whole spec: I wanted an assembly that was self-contained and would hold all 64 of these XSD files internally as resources, and I didn't want to put them in a temp directory.
I don't like to bake too much knowledge about the outside world into my schemas. The Xml Schema class will use a File System Resolver by default and fail to find the other 63 schemas.If it finds the document is not a valid XML schema, it generates the error telling the problem in the schema.