You might want to consider converting your DTD to an XSD. The XSD support in .NET is much better, and it's not hard at all to do what you want with an XSD.
> -----Original Message----- > From: Moderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of Sphinx > Sent: Wednesday, March 26, 2003 8:43 PM > To: [EMAIL PROTECTED] > Subject: [ADVANCED-DOTNET] Validating a xml file against a > dtd when no dtd reference is actually in the xml document > > > 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. > >
