Results 1 to 5 of 5

Thread: create xml from a text file

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    4

    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

  2. #2
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    4

    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

  4. #4
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196
    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    4

    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
  •  



Click Here to Expand Forum to Full Width