Net validating xml against schema

Net validating xml against schema

Both XmlDocument and XmlReader are

The code There are two functions and one sub that do the real work. It will work to use both, as you have done, but it does introduce some unnecessary confusion.

Typically, you'd only use one or the other. Exceptions A schema validation event occurred and no ValidationEventHandler object was specified. Most of the code can be found in partial form in the Visual Studio help files.

You are using an XmlReader object and an XmlDocument object. To fix it, you need to either set the XmlReader object's validation event handler, or you need to set the XmlDocument object's schema. Both XmlDocument and XmlReader are capable of performing schema validation, and they each have their own XmlSchemaSet and validation event handler that they use to perform the the validation.

To fix it you need toYou are using an XmlReader object

You know how vendors change their format and don't tell you. Inline schemas are ignored. Then it is a big guessing game to what changed. The Validate method performs infoset augmentation. Specifically, after successful validation, schema defaults are applied, text values are converted to atomic values as necessary, and type information is associated with validated information items.

The following are important notes to consider when using the Validate method. The reason the validation is not working is because you are adding the schema validation to the reader, but then you attach the ValidationEventHandler method to the XmlDocument object. Still the learning process is always enjoyable and never ends. Examples The following example illustrates use of the Validate method.

So I wrote a simple app that could do this validation. You have given half of what they need to each of them instead of all of what they need to one or the other.