Everyone who owns a website would have heard about the RSS phenomenon. Now you will get the opportunity to create your own RSS reader that will enable you to download and view RSS files on your desktop. This application will enable you to read RSS feeds from the Internet with the added advantage of being able to download XML files to your local hard drive.
begin //read links from links file *********************************** with tv1.Items.AddFirst( nil, 'RSS Links' ) do begin Selected := true; end; if fileexists('links.txt') then begin AssignFile(SomeTxtFile, 'links.txt'); Reset(SomeTxtFile); while not EOF(SomeTxtFile) do begin ReadLn(SomeTxtFile, buffer); with tv1.Items.AddChildFirst( tv1.Selected, buffer) do begin MakeVisible; end; end; CloseFile(SomeTxtFile); end //fileexists else begin with tv1.Items.AddFirst( nil, 'No RSS Links Found' ) do begin Selected := true; end; end ; end;
The above code basically loads the RSS links from a textfile that is located on the local disk and adds them to the treeview. You can only view these links once you are connected to the Internet. Next, double click on the OnDblClick event of the treeview component and add the following code:
procedure TForm1.tv1DblClick(Sender: TObject); begin if (tv1.Selected.Level <> 0) then begin fn:=tv1.Selected.Text; form1.Caption:=''; //update the form caption form1.Caption:='RSS XML File Reader - '+fn; wb.Navigate(fn); end; end;
All that happens in the above code is that it basically navigates the selected RSS link to the WebBrowser component. The link name is captured in the "fn" variable and then the form caption is updated with it. Then the program gets the RSS data from the Internet link (stored in the fn variable) and displays the contents in the WebBrowser component