PDA

View Full Version : txt to Xml Conversion


mustang
11th January 2006, 11:39
Does anyone know the easiest way to convert a text or csv file to Xml? Is there an online tool?

Coding Monkey
11th January 2006, 11:40
Quick Google search

http://www.dpawson.co.uk/java/uphill/

mustang
11th January 2006, 11:45
Its just a holding page. The Java source code doesn't help me.

Thanks anyway :)

mattk
11th January 2006, 12:06
Have you tried the Save As... XML Data option in Excel?

mustang
11th January 2006, 13:18
Have you tried the Save As... XML Data option in Excel?

I don't have that option. :?

mattk
11th January 2006, 13:44
Are you using Microsoft Excel 2003?

mustang
11th January 2006, 13:46
Are you using Microsoft Excel 2003?

Office 2000 SP3 unfortunately

Richard Conyard
11th January 2006, 14:04
Can you use VBS?

If so the following should help you out:


Dim strInfil, strOutfil
strInfil = "c:\myfile.txt"
strOutfil = "c:\myfile.xml"

Dim wrapper, field1, field2

wrapper = "container"
field1 = "csvcolumnone"
field2 = "csvcolumntwo"

set objFSO = createObject("Scripting.FileSystemObject")
set objINFIL = objFSO.openTextfile(strInfil, 1, 0 )
set objOUTFIL = objFSO.openTextfile(strOutfil, 2, 0)

while not objINFIL.atEndOfStream
arrFields = split( objINFIL.readline(), "," )
strOutLine = "<" & wrapper & "><" & field1 & ">" & arrFields(0) & _
"</" & field1 & "><" & field2 & ">" & arrFields(1) & "</" & field2 & _
"></" & wrapper & ">"
outOUTFIL.writeline strOutLine
wend

objOUTFIL.close
objINFIL.close



Obviously it's not great, but should give you a start