Delphi ActiveX Requires Chilkat v11.0.0+
Delphi ActiveX
Load XML Object from HTTP Response Body
Demonstrates how to load the HTTP response body directly into an XML object.Chilkat Delphi ActiveX Downloads
var
success: Integer;
http: TChilkatHttp;
resp: TChilkatHttpResponse;
xml: TChilkatXml;
begin
success := 0;
http := TChilkatHttp.Create(Self);
resp := TChilkatHttpResponse.Create(Self);
success := http.HttpStr('GET','https://www.chilkatsoft.com/exampledata/inventory.xml','','','',resp.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(http.LastErrorText);
Exit;
end;
xml := TChilkatXml.Create(Self);
// If we wish to transfer (instead of copy) the XML from the HttpResponse to the Xml, then add the keyword "TakeResponseBody" to UncommonOptions
// This could save memory for extremely large XML responses.
resp.UncommonOptions := 'TakeResponseBody';
resp.GetBodyXml(xml.ControlInterface);
Memo1.Lines.Add(xml.GetXml());
// Note: If UncommonOptions contained "TakeResponseBody", then the response BodyStr will now be empty:
Memo1.Lines.Add('----');
Memo1.Lines.Add(resp.BodyStr);