O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required