Validating XML using custom XmlReader

I wrote a custom XmlReader derived from XmlTextReader.  It implements a SAX-type parser that allows me to call one method on it to parse the entire file, pushing events to my handlers.

I want to use this as a validating reader, but I can't set the XmlSettings on it, they're read-only.  If I create a reader with XmlReader.Create passing it my custom XmlReader class and the XmlSettings, I can no longer get to my custom XmlReader methods because the returned XmlReader doesn't expost my class.

Under .NET 1.1, I simply wrote a custom XmlValidatingReader, but this is deprecated.  How do I go about this under .NET 2.0


Answer this question

Validating XML using custom XmlReader

  • Yan Li

    Do you want to use your class as validating reader or you want to wrap your class into a validating reader If former is true - why do you need anything else If latter - I don't think you can get your reader from a validating wrapper.
    You seems to be used to push mode, so you can easily add validation capabilities to your reader using XmlSchemaValidator class, see http://www.tkachenko.com/blog/archives/000476.html.



  • zoran maksimovic

    There is an extra overload for XmlReader:

    public static XmlReader Create ( XmlReader readerXmlReaderSettings settings )

    That allows you to create a validating reader from an existing reader.

    Regards,



  • Validating XML using custom XmlReader