|
-
Feb 15th, 2004, 08:18 AM
#1
Thread Starter
New Member
test file to xml conversion
Hello,
I have just purchased a version of visual basic .net and I am trying to write a vb program that will read in a pipe delimted text file and create an xml page.
The text file is very simple and is delimited with the pipe symbol.
The file contains......
123abc | £235,000
456def | £345,000
I would like to produce the following xml sheet from it.
<properties>
<property>
<property_id>abc123</property_id>
<price>£235,000</price>
</property>
<property>
<property_id>345def</property_id>
<price>£345,000</price>
</property>
</properties>
If somoene out there has done something like this before and could supply the basic code I could then learn from that and improve on it.
Many thanks
-
Feb 16th, 2004, 07:46 AM
#2
Fanatic Member
read your text file into a dataset and then you can directly save the dataset as an xml file.
Nick
-
Feb 16th, 2004, 08:55 AM
#3
Sleep mode
That's one way . nswan's idea would be even better and faster . However , you might need this code in either ways .
VB Code:
Sub ReadFile()
Dim sr As New IO.StreamReader("c:\test.txt")
While sr.Peek >= 0
Dim content As String = sr.ReadLine
Dim contents() As String = content.Split("|".ToCharArray)
For Each s As String In contents
MessageBox.Show(s)
'You formatting function here
Next
End While
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|