Hello.

I cannot get my .net xml validator working with an external dtd. I am hoping somebody could help me out here.

This is my code:

Dim settings As New XmlReaderSettings()
settings.ValidationType = ValidationType.DTD
settings.ProhibitDtd = False

AddHandler settings.ValidationEventHandler, AddressOf ValidateHandler

Dim xml As String = "C:\XmlDocuments\order.xml"
Dim xmlStream As New FileStream(xml, FileMode.Open)
Dim xmlReader As XmlReader = System.Xml.XmlReader.Create(xmlStream, settings)

Try
While xmlReader.Read()
End While
Catch ex As Exception
Response.Write(ex.Message)
Finally
xmlReader.Close()
xmlStream.Close()
xmlStream.Dispose()
End Try

Private Sub ValidateHandler(ByVal sender As Object, ByVal e As
ValidationEventArgs)

Response.Write(ex.Message)

End Sub

I am getting the following exception:

An error has occurred while opening external DTD 'file:///C:/Program Files/Microsoft Visual Studio 8/Common7/IDE/order.dtd': Could not find file 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\order.dtd'.

This is what I got in order.xml for the dtd declaration:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE order SYSTEM "order.dtd">

My code works with an inline DTD, but not using a xml file with an external DTD.

Thank you so much.