Get all tables from a XML File

The following function returns all tables in a list of string from a xml file.

Public Shared Function GetTableList(ByVal aFilename As String) As List(Of String)
      If Not File.Exists(aFilename) Then
        Throw New System.IO.FileNotFoundException("File not found!", aFilename)
        Exit Function
      End If
      Dim lstResult As New List(Of String)
      Dim ds As New DataSet
      Try
        ds.ReadXml(aFilename, XmlReadMode.InferSchema)
        For Each dt As DataTable In ds.Tables
          lstResult.Add(dt.TableName)
        Next
      Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical)
      End Try
      Return lstResult
    End Function

0 Antworten zu Get all tables from a XML File

  1. Bisher gibt es keine Kommentare.