[yunqa.de] Re: Question

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Mon, 02 May 2011 15:03:46 +0200

On 29.04.2011 08:26, D B wrote:

> I am trying to create a program that will read content from my blog
> and surface it in a windows application I am writing. I am
> relatively certain your components will allow me to do this but
> before I made any purchases. Basically, all I need to do is have the
> parser obtain the <meta name="description" content="foo"/> and return
> foo as a string so I can re-use that in my windows application.

There are a few specialized console demos in the folder


The one that shows how to extract <META ...> information is named


> I also need it to be able to read the first few lines of my last post
> in my blog and provide that text as a string so it can be re-used in
> my Delphi application.

For this, you can copy / paste / modify the function

function HtmlExtractText(
  const HtmlBuf: Pointer;
  const HtmlBufSize: Cardinal;
  const HtmlReadMethods: TDIUnicodeReadMethods;
  const ApplyMetaCharSet: Boolean;
  const NormalizeWhiteSpace: Boolean;
  const KeepLinks: Boolean;
  const EncodeEntities: Boolean): UnicodeString;

to your application. It is available as part of the demo in the folder


If you are new to DIHtmlParser, remember to register the tags and
attribute IDs plus decoding entities by calling the following functions
once before the parsing:

  { Register the HTML tags and attributes so the parser is able to
    correctly detect preformatted text, scripts, and styles. }
  RegisterHtmlTags; RegisterHtmlAttribs;
  { Also register the HTML entities to convert to their character
    represenation. &amul; --> ä }

A good place for this is the initialization section of your parsing unit.

Delphi Inspiration mailing list

Other related posts: