|
-
Feb 13th, 2004, 03:19 PM
#1
Thread Starter
New Member
create xml from a text file
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 13th, 2004, 04:34 PM
#2
Addicted Member
Code:
Dim strCon As String
Dim strSql As String
Dim Con As New OleDb.OleDbConnection()
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\path_to_Your Text_File_Directory\;Extended Properties=Text;"
strSql = "Select * from yourtextfile.txt"
Con.ConnectionString = Con
Con.Open()
Dim da As New OleDb.OleDbDataAdapter(strSql, Con)
da.SelectCommand.ExecuteNonQuery()
Dim ds As New DataSet("TextFiles")
da.Fill(ds, "TextFile")
'this line converts dataset to xml you can do what you want with it from there.
Console.WriteLine(ds.GetXml())
"And most of the evils of society can, in fact, be cured through information. We have a society that has been disinformed and based on the disinformation has made irrational choices. And that's what I mean by 'ignorance.' People, who ordinarily might be smart, are deprived of the data by which to make a rational decision, don't have the data to do it."
Frank Zappa
-
Feb 13th, 2004, 04:51 PM
#3
Thread Starter
New Member
Thank you
As I mentioned I am totally new to this and your answer seems somewhat amazing. I need to try and get this sorted out ASAP. If I send you exactly what I am trying to do could you do the complete code for me so that I could learn from the source and I would be willing to pay you.
Kind Regards
Rowan Trimmer
-
Feb 13th, 2004, 05:50 PM
#4
Addicted Member
I wish I had the time man, sorry. It's not very complicated stuff. I'm sure someone around here could help.
"And most of the evils of society can, in fact, be cured through information. We have a society that has been disinformed and based on the disinformation has made irrational choices. And that's what I mean by 'ignorance.' People, who ordinarily might be smart, are deprived of the data by which to make a rational decision, don't have the data to do it."
Frank Zappa
-
Feb 13th, 2004, 05:58 PM
#5
Thread Starter
New Member
Text to xml
Please see my first posting.
Can anyone help me ?
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
|