An object-oriented programming language developed by Microsoft that can be used in .NET.
Hi @OSVBNET ,
You can use the XmlDocument Class to save a copy of the xml file.
NotInheritable Class XmlDocumentSample
Private Sub New()
End Sub
Shared reader As XmlReader
Shared filename As String = "bookdtd.xml"
Public Shared Sub Main()
Dim eventHandler As New ValidationEventHandler(AddressOf XmlDocumentSample.ValidationCallback)
Try
' Create the validating reader and specify DTD validation.
Dim settings As New XmlReaderSettings()
settings.DtdProcessing = DtdProcessing.Parse
settings.ValidationType = ValidationType.DTD
AddHandler settings.ValidationEventHandler, eventHandler
reader = XmlReader.Create(filename, settings)
' Pass the validating reader to the XML document.
' Validation fails due to an undefined attribute, but the
' data is still loaded into the document.
Dim doc As New XmlDocument()
doc.Load(reader)
Console.WriteLine(doc.OuterXml)
Finally
If Not (reader Is Nothing) Then
reader.Close()
End If
End Try
End Sub
' Display the validation error.
Private Shared Sub ValidationCallback(ByVal sender As Object, ByVal args As ValidationEventArgs)
Console.WriteLine("Validation error loading: {0}", filename)
Console.WriteLine(args.Message)
End Sub
End Class
Best Regards.
Jiachen Li
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.