This documentation is archived and is not being maintained.

XmlDocument Load-Time Validation

.NET Framework 1.1

You can validate XML documents as they are loaded by using the Load method to load the XmlDocument with an XmlValidatingReader.

The following code example shows the XmlDocument, doc, loading an XmlValidatingReader, reader, as input.

Dim doc as XmlDocument = new XmlDocument()
Dim tr as XmlTextReader = new XmlTextReader("Sample.xml")
Dim reader as XmlValidatingReader = new XmlValidatingReader(tr)
XmlDocument doc = new XmlDocument();
XmlTextReader tr = new XmlTextReader("Sample.xml");
XmlValidatingReader reader = new XmlValidatingReader(tr);

See Also

Validation of XML with Schemas | XmlDocument Constructor