Imports System
Imports System.Xml.Linq
Imports Microsoft.VisualBasic.FileIO
Imports System.Text
Imports System.IO
Public Class MainClass
Public Shared Sub Main(ByVal args As String())
Dim xmlTree As XElement
Using parser As TextFieldParser = My.Computer.FileSystem.OpenTextFieldParser("data.txt")
parser.TextFieldType = FieldType.Delimited
parser.Delimiters = New String() {","}
parser.HasFieldsEnclosedInQuotes = True
xmlTree = <Employees></Employees>
Dim currentRow As String()
Do While Not parser.EndOfData
currentRow = parser.ReadFields
xmlTree.Add(<Employee id=<%= currentRow(0) %>>
<Name><%= currentRow(1) %></Name>
<Title><%= currentRow(2) %></Title>
<HireDate><%= currentRow(3) %></HireDate>
<HourlyRate><%= currentRow(4) %></HourlyRate>
</Employee>)
Loop
End Using
Console.WriteLine(xmlTree)
End Sub
End Class
|