XML from a site

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

XML from a site

Chris Moody
Hi all,

Currently working on an app which needs to be able to read an XML from a website. Looking at the page at http://wiki.freepascal.org/XML_Tutorial it appears there is no way to get XML directly from a URL.

Do I need to pull the page down via :


function GetWebPageContent(const Url: string): String;
var fs: TStringList; HTTP: THTTPSend;
begin
   fs := TStringList.Create;
   HTTP := THTTPSend.Create;
   try
      HTTP.HTTPMethod('GET', Url);
      fs.LoadFromStream(Http.Document);
      Result := fs.Text;
   finally
      fs.Free;
      http.Free;
   end;
end;         

Or is there a way to pass an URL to ReadXMLFile?

Thanks in advance!

Chris

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: XML from a site

Sven Barth-2

Am 17.07.2015 08:11 schrieb "Chris Moody" <[hidden email]>:
>
> Hi all,
>
> Currently working on an app which needs to be able to read an XML from a website. Looking at the page at http://wiki.freepascal.org/XML_Tutorial it appears there is no way to get XML directly from a URL.
>
> Do I need to pull the page down via :
>
>
> function GetWebPageContent(const Url: string): String;
> var fs: TStringList; HTTP: THTTPSend;
> begin
>    fs := TStringList.Create;
>    HTTP := THTTPSend.Create;
>    try
>       HTTP.HTTPMethod('GET', Url);
>       fs.LoadFromStream(Http.Document);
>       Result := fs.Text;
>    finally
>       fs.Free;
>       http.Free;
>    end;
> end;         
>
> Or is there a way to pass an URL to ReadXMLFile?

There is not and there should not be. But you should be able to pass a stream to an equivalent function of ReadXMLFile, I simply don't know its name right now... Just check the unit ReadXMLFile is declared in.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: XML from a site

leledumbo
Administrator
> There is not and there should not be

Agree in the name of modularity. AFAIK fphttpclient has overloaded methods that accept TStream so it's still a one liner code (if you use the class method version).