XmlDocument doc = new XmlDocument();In the second example, the user was browsing for an XML file on the network and they requested the ability to use a non-validating file for testing purposes.
doc.XmlResolver = null;
XmlValidatingReader xmlReader =
new XmlValidatingReader(new XmlTextReader(openFileDialog1.FileName));
xmlReader.ValidationType = ValidationType.None;
Monday, April 9, 2007
Turn Off DTD Validation When Processing an XML File
I've had two situtions recently where I needed to turn off DTD validation before processing an XML file in a .NET app. The ability to do so is in the class library, but there aren't a lot of examples. Here are two ways using two different objects: