Imports System.IO Imports System.Xml Imports System.Xml.Schema Imports System.Data Imports System.Data.SqlTypes Imports System.Data.SqlClient Public Class frmErrorAVQ_File Private m_Success As Boolean = True Dim Resultat As String = "" Dim intFilename As String Sub New(ByVal filename As String) MyBase.New() InitializeComponent() intFilename = filename End Sub Private Sub frmErrorAVQ_File_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TextBox1.Text = Get_FileInhalt(intFilename) Me.Label4.Text = intFilename End Sub Private Function Get_FileInhalt(ByVal filename As String) Dim resultat As String = "" Dim daten As String() daten = IO.File.ReadAllLines(filename, System.Text.Encoding.GetEncoding("ISO-8859-1")) Dim int As Integer Dim l As Integer = 0 Dim z As Integer = 0 For Each s As String In daten l = l + 1 z = 0 For Each ch As Char In s z = z + 1 If ch = "" Then resultat = resultat & "Zeile " & Trim(Str(l)) & ", Pos. " & Trim(Str(z)) & ": ungültiges Zeichen: " & ch & vbTab & daten(l - 1) & vbNewLine End If 'int = Microsoft.VisualBasic.AscW(ch).Parse(Globalization.NumberStyles.HexNumber) 'If Microsoft.VisualBasic.AscW(ch) <= 31 Then ' int = Microsoft.VisualBasic.AscW(ch).Parse(Globalization.NumberStyles.HexNumber) ' If Microsoft.VisualBasic.AscW(ch) <> 9 Then ' Try ' resultat = resultat & "Zeile " & Trim(Str(l)) & ", Pos. " & Trim(Str(z)) & " ungültiges Zeichen:" & ch ' Catch ex As Exception ' resultat = resultat & "Zeile " & Trim(Str(l)) & ", Pos. " & Trim(Str(z)) & " ungültiges Zeichen" ' End Try ' End If 'End If Next Next Return resultat End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Close() End Sub Dim instance As XmlReaderSettings Dim handler As ValidationEventHandler Private Function xx(ByVal infile As String) As String Dim settings As XmlReaderSettings = New XmlReaderSettings() settings.CheckCharacters = True settings.ValidationType = ValidationType.Schema settings.ValidationFlags = settings.ValidationFlags Or XmlSchemaValidationFlags.ProcessInlineSchema settings.ValidationFlags = settings.ValidationFlags Or XmlSchemaValidationFlags.ReportValidationWarnings AddHandler settings.ValidationEventHandler, AddressOf ValidationCallBack ' Create the XmlReader object. Dim reader As XmlReader = XmlReader.Create(infile, settings) ' Parse the file. While (reader.Read()) End While End Function ' Display any warnings or errors. Private Shared Sub ValidationCallBack(ByVal sender As Object, ByVal args As ValidationEventArgs) If (args.Severity = XmlSeverityType.Warning) Then Console.WriteLine(" Warning: Matching schema not found. No validation occurred." + args.Message) Else Console.WriteLine(" Validation error: " + args.Message) End If End Sub 'Private Function validatexml(ByVal infile As String) As Boolean ' 'First we create the xmltextreader ' Dim xmlr As New XmlTextReader(infile) ' 'We pass the xmltextreader into the xmlvalidatingreader ' 'This will validate the xml doc with the schema file ' 'NOTE the xml file it self points to the schema file ' Dim xmlvread As New XmlValidatingReader(xmlr) ' ' Set the validation event handler ' AddHandler xmlvread.ValidationEventHandler, AddressOf ValidationCallBack ' m_Success = True 'make sure to reset the success var ' ' Read XML data ' Try ' While (xmlvread.ReadContentAsString) ' End While ' Catch ex As Exception ' Resultat = Resultat + ex.Message + vbNewLine ' End Try ' 'Close the reader. ' xmlvread.Close() ' 'The validationeventhandler is the only thing that would set m_Success to false ' Return m_Success 'End Function 'Private Sub ValidationCallBack(ByVal sender As Object, ByVal args As ValidationEventArgs) ' 'Display the validation error. This is only called on error ' m_Success = False 'Validation failed ' 'Resultat = Resultat + (args.Message + vbNewLine) 'End Sub End Class