From: Peter Szinek Date: 2006-12-06T17:27:47+09:00 Subject: Re: Newbie: working with a text file and converting to xml Adam Teale wrote: > hi Guys, > > I have a tab-delimited text file that I would like to convert into an > xml file that can be read/imported into Apple's Final Cut Pro. > > The text file is 2 columns. > The first column is the time (timecode) > The second column is text (for sub-titling) Could you send us 2 example files? I guess the text file format is obvious (but better to work with a real-life example) but I am not so sure about the Final Cut Pro XML (or is it just a plain simple XML?) Until then, check out this code: ============================================================ input = <TIMECODE SUB-TITLING TEMPLATE result = "\n" input.split(/\n/).each do |line| data = line.split(/\t/) result += template.sub('TIMECODE'){data[0]}.sub('SUB-TITLING'){data[1]} end result += '' puts result ============================================================ output: 0.12 Salut, Foo! 0.15 Hola Bar! Did you see Baz? 0.22 I guess he is hanging around with Fluff and Ork. Cheers, Peter __ http://www.rubyrailways.com