Get all columns from a xml file

The following function returns all columns from a xml file as a list of string.

Public Shared Function GetColumnList(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
          For Each dc As DataColumn In dt.Columns
            lstResult.Add(dc.Caption)
          Next
        Next
      Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical)
      End Try
      Return lstResult
    End Function
  End Class

0 Antworten zu Get all columns from a xml file

  1. Bisher gibt es keine Kommentare.