Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

HTML 2 Text converter

Title: HTML 2 Text converter Question: Is there any way to convert html file to text ignoring html codes Answer: To convert HTML file to Text you can do it with some lopes. It is very easy. just look for "" and "Here below i am giving whole main unit. unit main; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ImgList, ToolWin, ExtCtrls; type TForm1 = class(TForm) Memo1: TMemo; Memo2: TMemo; OpenDialog1: TOpenDialog; StatusBar1: TStatusBar; ToolBar1: TToolBar; ImageList1: TImageList; ToolButton1: TToolButton; ToolButton2: TToolButton; Splitter1: TSplitter; procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button2Click(Sender: TObject); var oldfile,newfile:textfile; ch:string[1]; finish:boolean; soz:string; i:integer; begin memo1.Lines.SaveToFile('mek.dat'); finish:=true; try assignfile(oldfile,'mek.dat'); reset(oldfile); assignfile(newfile,'mek1.dat'); rewrite(newfile); while(not eof(oldfile))do begin while(not eoln(oldfile))do begin read(oldfile,ch); if (ch='')or(finish=false)then begin if (ch='')then read(oldfile,ch); while (ch' begin write(newfile,ch); read(oldfile,ch); finish:=false; end; if (ch=' finish:=true; end; end; write(newfile,ch); readln(oldfile); writeln(newfile); end; finally closefile(oldfile); closefile(newfile); ///////////////&nbsp///////////////// assignfile(oldfile,'mek1.dat'); reset(oldfile); assignfile(newfile,'mek.dat'); rewrite(newfile); while(not eof(oldfile))do begin while(not eoln(oldfile))do begin read(oldfile,ch); soz:=''; if (ch='&')then begin soz:='&'; for i:=0 to 4 do begin read(oldfile,ch); soz:=soz+ch; end; if(soz=' ')then write(newfile,' '); end else write(newfile,ch); end; readln(oldfile); writeln(newfile); end; closefile(oldfile); closefile(newfile); //////////////////////////////////////// memo2.Lines.LoadFromFile('mek.dat'); deletefile('mek.dat'); deletefile('mek1.dat'); end; end; procedure TForm1.Button1Click(Sender: TObject); begin opendialog1.Filter:='Html Files *.htm|*.htm;*.html'; if(opendialog1.Execute)then begin memo1.Lines.LoadFromFile(Opendialog1.FileName); end; end; end. /////////////////////// I hope tha it will help you.