Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2010, 02:10 AM
arwar arwar is offline
Member
 
Join Date: May 2010
Posts: 31
Default Rss

this is an old post:

Code:
procedure TfrmMain.GetURL_1;
const
  ADPXMLBLOG = 'http://feeds.reuters.com/reuters/topNews';
var
  ADPLocalFile : TFileName;
begin
  ADPLocalFile := IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName)) + 'RSS\' + comboxFileName1.Text;

  Screen.Cursor:=crHourglass;
  try
    if not DownloadURLFile(ADPXMLBLOG, ADPLocalFile)  then
    begin
      Screen.Cursor:=crDefault;
      Raise Exception.CreateFmt('Unable to connect to the Internet, make sure you are connected!',[]);
      Exit;
    end;

    if not FileExists(ADPLocalFile) then
    begin
      Screen.Cursor:=crDefault;
      raise exception.Create('Can''t locate the *xml* file?!');
      Exit;
    end;

    xmlDocRSS.FileName := ADPLocalFile;
    xmlDocRSS.Active:=True;
  finally
    Screen.Cursor:=crDefault;
  end;
end;
i need to work with it but i can't find

where

xmlDocRSS.

lives. is it a unit or a component that i need to import?

Last edited by Norrit; 05-19-2010 at 08:03 AM. Reason: added code-tags
Reply With Quote
  #2  
Old 05-19-2010, 08:02 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default

My guess that it's a TXmlDocument placed on the form and called XmlDocRss
Reply With Quote
  #3  
Old 05-19-2010, 11:21 AM
Hitman Hitman is offline
Senior Member
 
Join Date: Oct 2006
Location: A nice place on earth
Posts: 309
Default

Yes,
It is as Norrit says --> TXMLDOCUMENT.
__________________
ERRARE HUMANUM EST
Reply With Quote
  #4  
Old 05-19-2010, 01:57 PM
arwar arwar is offline
Member
 
Join Date: May 2010
Posts: 31
Default

thanks guys, that got it past the compiler but it blows up with an 'unauthorized access exception' when trying to execute:

xmlDocRSS.Active:=True;

the document is there, looks good from a cursory standpoint. i have not done much with RSS except parse by brute force. what are my options for displaying the data in a VCL forms app? i don't need anything fancy, a listbox will do, or something that will parse it and dump the data into a CSV or whatever.

thanks again for the responses...
Reply With Quote
  #5  
Old 05-19-2010, 04:00 PM
Hitman Hitman is offline
Senior Member
 
Join Date: Oct 2006
Location: A nice place on earth
Posts: 309
Default

Quote:
Originally Posted by arwar View Post
thanks guys, that got it past the compiler but it blows up with an 'unauthorized access exception' when trying to execute:

xmlDocRSS.Active:=True;

the document is there, looks good from a cursory standpoint. i have not done much with RSS except parse by brute force. what are my options for displaying the data in a VCL forms app? i don't need anything fancy, a listbox will do, or something that will parse it and dump the data into a CSV or whatever.

thanks again for the responses...
Are you trying to get reuters xml as in my post in the past which you are using?
If yes,
It should work.
If not,
Can you give us a bit more infor about what and from where you are trying to get the xml file?

There are some RSS feeds which you cannot download with this code.
__________________
ERRARE HUMANUM EST
Reply With Quote
  #6  
Old 05-19-2010, 04:11 PM
arwar arwar is offline
Member
 
Join Date: May 2010
Posts: 31
Default

no not reuters

i got past runtime error ( XMLDocRSS := TXMLDocument.Create(nil); )

the feed is:

url:='http://xml.matchbook.com//xmlfeed/feed?sport-id'+
'=&vendor=awarner&sport-name=&short-name=BB&last=';

and i have to append a timestamp at the end.

i get text (local) file fine and it generates an .XML file as well. all i need now is couple of bits of code to display the data.

also do i have to free the TXMLDocument, and if so what is the syntax??

thanks again for your help
Reply With Quote
  #7  
Old 05-19-2010, 07:11 PM
Hitman Hitman is offline
Senior Member
 
Join Date: Oct 2006
Location: A nice place on earth
Posts: 309
Default

Quote:
Originally Posted by arwar View Post
no not reuters

i got past runtime error ( XMLDocRSS := TXMLDocument.Create(nil); )

the feed is:

url:='http://xml.matchbook.com//xmlfeed/feed?sport-id'+
'=&vendor=awarner&sport-name=&short-name=BB&last=';

and i have to append a timestamp at the end.

i get text (local) file fine and it generates an .XML file as well. all i need now is couple of bits of code to display the data.

also do i have to free the TXMLDocument, and if so what is the syntax??

thanks again for your help
Hello,
I will help you if you can clear this a bit more,

is this what you need?
HTML Code:
http://xml.matchbook.com//xmlfeed/feed?
And yes,
You should free the document as following,
Code:
function DownloadURLFile(const ADPXMLBLOG, ADPLocalFile : TFileName) : boolean;
begin
  Result:=True;
  with TDownLoadURL.Create(nil) do
  try
    URL:=ADPXMLBLOG;
    Filename:=ADPLocalFile;
    try
      ExecuteTarget(nil);
    except
      Result:=False;
    end;
  finally
    Free;
  end;
end;
Code:
procedure TfrmMain.GetURL_1;
var
  ADPXMLBLOG : string;
  ADPLocalFile : TFileName;
begin
  Screen.Cursor:=crHourglass;
  {Downloading the feed 1}
  ADPXMLBLOG := comboxUrl1.Text;
  ADPLocalFile := IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName)) + 'RSS\' + comboxFileName1.Text;
  try
    if not DownloadURLFile(ADPXMLBLOG, ADPLocalFile)  then
    begin
      //Raise Exception.CreateFmt('Unable to connect to the Internet, make sure you are connected!',[]);
      Exit;
    end;
    if not FileExists(ADPLocalFile) then
    begin
      raise exception.Create('Can''t locate the *xml* file?!');
      Exit;
    end;

    xmlDocRSS.FileName := ADPLocalFile;
    xmlDocRSS.Active:=True;
  finally
    Screen.Cursor:=crDefault;
  end;
end;
This code is all you need to download the file.
This is also the code which I am using in one of my app and it works perfectly.
__________________
ERRARE HUMANUM EST

Last edited by Hitman; 05-19-2010 at 07:18 PM.
Reply With Quote
  #8  
Old 05-19-2010, 08:11 PM
arwar arwar is offline
Member
 
Join Date: May 2010
Posts: 31
Default

yes great - like i said in my last post it works fine once i initialized the document - the file downloads just like it is supposed to. and now i will add the line to free the document and that should be good too.


but how do i display it on my form?

thanks
Reply With Quote
  #9  
Old 05-20-2010, 06:04 AM
Hitman Hitman is offline
Senior Member
 
Join Date: Oct 2006
Location: A nice place on earth
Posts: 309
Default

Quote:
Originally Posted by arwar View Post
yes great - like i said in my last post it works fine once i initialized the document - the file downloads just like it is supposed to. and now i will add the line to free the document and that should be good too.


but how do i display it on my form?

thanks
Are you trying to display the feed on the form as an xml or something else?
__________________
ERRARE HUMANUM EST
Reply With Quote
  #10  
Old 05-20-2010, 08:57 AM
arwar arwar is offline
Member
 
Join Date: May 2010
Posts: 31
Default

as an academic exercise, i would like to be able to display the data by populating a ttreelist - which i assume is XML??? so you can click on the nodes and have data revealed.

as a practical matter what i need is to is loop through the xml file and have the data get assigned to records, which i can then use for other purposes, like displaying certain fields in a stringgrid.

thanks for your help
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 04:21 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.