Delphi DLL
Delphi DLL
Load XML from a Remote URL
Demonstrates how to load XML from a remote URL, such as https://www.chilkatsoft.com/hamlet.xmlChilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, StringBuilder, Xml;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
sbXml: HCkStringBuilder;
xml: HCkXml;
begin
success := False;
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
sbXml := CkStringBuilder_Create();
// Download the XML from the URL into sbXml
success := CkHttp_QuickGetSb(http,'https://www.chilkatsoft.com/hamlet.xml',sbXml);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
xml := CkXml_Create();
// Load the XML contained in sbXml
success := CkXml_LoadSb(xml,sbXml,True);
if (success = False) then
begin
Memo1.Lines.Add(CkXml__lastErrorText(xml));
Exit;
end;
Memo1.Lines.Add('Success.');
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbXml);
CkXml_Dispose(xml);
end;