Name

XmlValidatingReader

Synopsis

This class is an XML reader that supports DTD and Schema validation. The type of validation to perform is contained in the ValidationType property, which can be DTD, Schema, XDR, or Auto. Auto is the default and determines which type of validation is required, if any, based on the document. If the DOCTYPE element contains DTD information, that is used. If a schema attribute exists or there is an inline <schema>, that schema is used.

This class implements an event handler that you can set to warn of validation errors during Read() operations. Specifically, a delegate instance of type System.Xml.Schema.ValidationEventHandler can be set for the ValidationEventHandler event in this class. This delegate instance is invoked whenever the XmlValidatingReader finds an schema-invalid construct in the XML document it is reading, giving the delegate a chance to perform whatever error-handling is appropriate. If no event handler is registered, a XmlException is thrown instead on the first error.

public class XmlValidatingReader : XmlReader : IXmlLineInfo {
// Public Constructors
   public method XmlValidatingReader(
        System.IO.Stream xmlFragment, XmlNodeType fragType, 
        XmlParserContext context);  
   public method XmlValidatingReader(string xmlFragment, 
        XmlNodeType fragType, XmlParserContext context);  
   public method XmlValidatingReader(XmlReader reader);  
// Public Instance Properties
   public override field int AttributeCount{get; }               // overrides XmlReader public override ...

Get C# in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.