Delphi Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Delphi Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Byte Array
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
Bzip2
LZW
Bz2
Icon

Type Conversion

 

Article: Understanding COM References in Delphi

HTTP GET - Download and Parse HTML

Downloads an HTML page from the Singapore Exchange and parses a row of options prices from an HTML table.

Download Chilkat XML ActiveX

Download Chilkat HTTP ActiveX

uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls,
    CHILKATXMLLib_TLB,
    HTMLTOXMLLib_TLB,
    CHILKATHTTPLib_TLB,
    OleCtrls;

...

procedure TForm1.Button1Click(Sender: TObject);
var
http: TChilkatHttp;
success: Integer;
html: String;
htmlToXml: THtmlToXml;
xmlStr: String;
xml: CHILKATXMLLib_TLB.IChilkatXml;
node: CHILKATXMLLib_TLB.IChilkatXml;

begin
http := TChilkatHttp.Create(Self);

//  Any string unlocks the component for the 1st 30-days.
success := http.UnlockComponent('Anything for 30-day trial');
if (success <> 1) then
  begin
    ShowMessage(http.LastErrorText);

  end;

//  Send the HTTP GET and return the content in a string.

html := http.QuickGetStr('http://esite.sgx.com/live/dt/DTFuture.asp?JBFE');

//  Use the Chilkat HTML-to-XML component to convert
//  the HTML to parsable XML:
htmlToXml := THtmlToXml.Create(Self);

//  Any string argument automatically begins the 30-day trial.
success := htmlToXml.UnlockComponent('30-day trial');
if (success <> 1) then
  begin
    ShowMessage('HtmlToXml component unlock failed');

  end;

//  Indicate the charset of the output XML we'll want.
htmlToXml.XmlCharset := 'utf-8';

//  Set the HTML:
htmlToXml.Html := html;

//  We won't need the scripts or images, so drop those tags...
htmlToXml.DropTagType('img');
htmlToXml.DropTagType('script');

//  Get the XML:

xmlStr := htmlToXml.ToXml();

//  Load the XML into the Chilkat XML parser:
xml := TChilkatXml.Create(Self).ControlInterface;
xml.LoadXml(xmlStr);

//  success = xml.SaveXml("out.xml");

//  Find a known point in the XML.  In this case we'll look for the text node
//  containing this string: "Chg From Prev Settle"
node := xml.SearchForContent(nil,'text','Chg From Prev Settle');
if (node = nil ) then
  begin
    ShowMessage('Did not find Chg From Prev Settle');

  end;

//  Move up to the TD node:
node.GetParent2();

//  Move up to the TR node:
node.GetParent2();

//  Move to the next row (i.e. next TR)
node.NextSibling2();

node.FirstChild2();
node.NextSibling2();

Memo1.Lines.Add('Expire Month/Year: ' + node.GetChildContent('text'));
node.NextSibling2();

Memo1.Lines.Add('Last: ' + node.GetChildContent('text'));
node.NextSibling2();

Memo1.Lines.Add('Change: ' + node.GetChildContent('text'));
node.NextSibling2();

//  ...

success := node.SaveXml('row.xml');


end;

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · XML Parser