Re: my dilemma -- hundreds of record types
- Posted by tone.skoda at gmx.net Nov 16, 2002
- 450 views
I have written a HTML parser which has three events: on_start_tag, on_end_tag and on_data. it isnt on my web page or in archives yet. if you want it i can upload it? ----- Original Message ----- From: "Chris Saik" <csaik2002 at yahoo.com> Sent: Friday, November 15, 2002 10:30 PM Subject: Re: my dilemma -- hundreds of record types > > <snip> > > > > > Kat wrote: > > > > > Use gets() to read the file into a sequence, and > > then a simple loop thru > > > the sequence, to find the tags you are looking > > for. > > > > Almost:) gets() reads one line up to the c/r from a > > file. In order to get an > > entire file, which you might as well do if the files > > aren't really huge: > > > > -- (tested) > > atom fn > > object line, text > > > > fn = open("test.txt","r") > > > > text = {} -- start with empty buffer > > while 1 do -- loop forever > > line = gets(fn) -- read a line > > if atom(line) then exit -- get out of the forever > > loop! > > else text = append(text,line) -- add line to > > buffer > > end if > > end while > > > > for i = 1 to length(text) do -- iterate thru the > > buffer > > if match("<YEAR>",text[i]) then -- looking for the > > <YEAR> tag > > puts(1,text[i]) -- if tag is found, print the > > entire line > > end if > > end for > > Thank you Irv. I'm confused over one thing though... > what if the data following the tag is several lines > long, as in a paragraph? How would I print the entire > data within the field, and stop when the program > reaches the next tag? > > Thanks for your assistance, > > Chris > > > >