Validatingreader is obsolete
-
Hi, I m currently developing a project on Xml Editor in vb.net...While trying to validate the xml against dtd i m getting the following error : XmlValidatingReader is obsolete. I tried using XmlReaderSettings but its showing an error saying that "The XmlSchemaSet on the document is either null or has no schemas in it. Provide schema information before calling Validate." This is the coding i ve written : Dim xmlV As New XmlDocument Dim xmlP As New XmlTextReader(TempFile) Dim settings As New XmlReaderSettings Dim eventhandler As ValidationEventHandler eventhandler = New ValidationEventHandler(AddressOf WriteErrorLog) xmlV.Validate(eventhandler) settings.ValidationType = ValidationType.DTD settings.ProhibitDtd = False Dim reader As XmlReader reader = XmlReader.Create(xmlP, settings) xmlV.Load(reader) ErrStr = "" ListBox1.Items.Clear() IsValid = True Do Try If reader.Read() Then lineInf = CType(xmlV, IXmlLineInfo) End If Catch exx As Exception Try IsValid = False If lineInf.HasLineInfo Then ErrStr = lineInf.LineNumber.ToString + ": " + lineInf.LinePosition.ToString + " " + exx.Message End If If exx.Message.IndexOf("EndElement") > 1 Then Exit Do End If ListBox1.Items.Add(ErrStr) Catch eeex As Exception MsgBox("Some unexpected error occurred " + vbNewLine + eeex.Message, MsgBoxStyle.Information, "Error") Exit Do End Try End Try Loop While Not xmlP.EOF reader.Close() xmlP.Close() Me.Cursor = System.Windows.Forms.Cursors.Default If IsValid = False Then MsgBox("File is not valid", MsgBoxStyle.Exclamation, "Error") Else MsgBox("File is valid", MsgBoxStyle.Information, "OK") End If End Sub Can anyone pls help me out in finding the error??? THanks in advance.