Hello,

How to validate a xml document against a dtd when there is no dtd reference in the xml 
document. I have used XMLParserContext and XmlValidatingReader classes. But, it is not 
working. I used the following code..

//PEdConfig is the name of the dtd

XmlParserContext context = new XmlParserContext(null, null, "PEdConfig", null, null, 
null, "", "", XmlSpace.None);

//strFileName contains  name of the xml file

FileStream filestreamSource = new FileStream(strFileName, FileMode.Open, 
FileAccess.Read);


XmlValidatingReader reader  = new XmlValidatingReader(filestreamSource, 
XmlNodeType.Element, context);

 reader.ValidationType = ValidationType.DTD;


while(reader.Read())

{

}

Thanks ,

Chito.

Reply via email to