The XmlTextReader class found in the System.Xml assembly
offers a powerful way to traverse XML documents in a forward-only, non-cached
manner. However, it cannot be used on its own to validate XML documents
against DTDs or XML schemas. This example provides a reusable class named
Validator that can be used to validate XML documents using the
XmlValidatingReader in the System.Xml namespace. Any errors found during
the validation process can optionally be logged to a file. This particular
example validates against an XSD schema and will fail because the XML
document contains an invalid element named "golfer1."
This sample is from the book XML
for ASP.NET Developers by Dan Wahlin (Sams Publishing)
|