reading a specific data in .txt file to put in specific tag in xml in vb.net..pls help..

sample: BL% PHP 103025 and so on...
NL%
..
..

BL% and NL% are indicators where data should be placed in a specific segment in xml
PHP must be placed inside <currency></currency> tag..
103025 must be placed inside <amount></amount> tag..

This code may help:

Private Sub Form1_Load(ByVal sender As System.Object, _
                           ByVal e As System.EventArgs) _
                           Handles MyBase.Load
        Dim filename As String = "afile.txt" ' Your file name/path
        Dim filereader As New System.IO.StreamReader(filename) ' Open the file for reading
        Dim readline As String
        Dim data As String
        Dim dataparts(1) As String

        While Not filereader.EndOfStream
            readline = filereader.ReadLine ' Reads a line from the text file

            Select Case readline.Substring(0, 3) ' Reads the first 3 Characters of the line
                Case "BL%"
                    data = readline.Substring(4) ' Reads the data in front of 'BL%'
                    dataparts = data.Split(" ") ' Breaks the data into two and store them in the dataparts array
                    ' Add your codes for writing the data to the XML file in the 'BL%' segment between the currency and amount tag here

                Case "NL%"
                    data = readline.Substring(4)
                    dataparts = data.Split(" ")
                    ' Add your codes for writing the data to the XML file in the 'NL%' segment here
            End Select
        End While

    End Sub

I am assuming that you already know how to add the data to XML file(if you don't, you may learn it here) and that the data from text file you are reading from is stored in this way:
BL% PHP 103025
NL% Tag1 Tag2

This article has been dead for over six months. Start a new discussion instead.