In this part of the article, we will discuss how to get an RSS file from a website, and store it on the local disk for easy viewing. This way we do not need to be connected to the Internet.
Finishing an RSS Reader - Getting files from a website (Page 3 of 4 )
So our application will now let us view RSS links in a web browser. It will also let us view locally stored XML files in a list view. But we have not yet discussed how to get the RSS or XML file from a website. So let's get on with it.
In Delphi, open up form3 and add an idHTTP component from the Indy clients tab. Then rename the TEdit to "url." And put http:// in its Text property on the object inspector. Form3 should look something like this:
Double click on the button and add the following code:
procedure TForm3.btnURLClick(Sender: TObject); var FStream: TFileStream; begin FStream := TFileStream.Create('feed.xml', fmCreate); try IdHTTP1.Get(url.Text, FStream); finally FStream.Free; form1.wb.Navigate(url.Text); end; close; end;
Before downloading the file, we create a TStream object to store its content, as the code below demonstrates: