| | |
reading a specific data in .txt file to put in specific tag in xml in vb.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2008
Posts: 36
Reputation:
Solved Threads: 0
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..
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..
•
•
Join Date: Dec 2008
Posts: 10
Reputation:
Solved Threads: 0
Re: reading a specific data in .txt file to put in specific tag in xml in vb.net
0
#2 Dec 11th, 2008
This code may help:
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
VB Syntax (Toggle Plain Text)
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
Last edited by NEo4; Dec 11th, 2008 at 4:00 am.
![]() |
Similar Threads
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
- Open In New Window Php (PHP)
Other Threads in the VB.NET Forum
- Previous Thread: VB 2008 compile error
- Next Thread: complete records between two dates
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access advanced application array basic beginner browser button buttons center click client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function html images input lib listview map mobile module monitor msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read regex remove right-to-left save search serial settings shutdown socket sorting sqldatbase sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol validation vb vb.net vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms winsock wpf wrapingcode xml year





