Validating xml file against schema
I have looked at many posts to see how to use the XML validating reader (Now just XMLReader. The data validates 100% using XML Spy from Altova but not using the XMLReader in C#. The error that occurs trying to find the type String20, which is my first custom data type in my schema.
Read(schema Reader, Schema Validation Handler); asset. I am new to so any sample code help will be appreciated. Public Class Xml Validation Error Builder Private _errors As New List(Of Validation Event Args)() Public Sub Validation Event Handler(By Val sender As Object, By Val args As Validation Event Args) If args. Count 0 Then Dim builder As New String Builder() builder. Add(Nothing, xsd File Path) Dim error Builder As New Xml Validation Error Builder() doc. Append Line(" error(s) were found while validating the XML document against the XSD:") For Each i As Validation Event Args In _errors builder. Get Errors() If errors Text Is Not Nothing Then Throw New Exception(errors Text) End If Return doc End Function Public Sub Load Xml(xml File Path As String, xsd File Path As String) Dim settings As New Xml Reader Settings() settings. Validation Event Handler) Dim reader As Xml Reader = Xml Reader.Validation Event Handler)) Dim errors Text As String = error Builder.Get Errors() If errors Text Is Not Nothing Then Throw New Exception(errors Text) End If Return doc End Function As for loading the data from the XML document into a database, it's impossible to say how, precisely, to do that without knowing the schema of the XML document, the schema of the database, the kind of database, etc.