The sample runs the TclHtmlParser component and extracts inner HTML from specific tags.
 
 
procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  tag: TclHtmlTag;
begin
  Memo2.Lines.Clear();
 
  clHtmlParser1.IncludeClosingTags := True;
  clHtmlParser1.ParseMethod := pmAll;
  clHtmlParser1.Parse(Memo1.Lines);
 
  for i := 0 to clHtmlParser1.Tags.Count - 1 do
  begin
    tag := clHtmlParser1.Tags[i];
    if (tag.Name = 'div') 
    and (tag.AttributeValue('class') = 'tvRow tvFirst hasLabel tvFirst') 
    then
    begin
      Memo2.Lines.Add(GetInnerHtml(tag.Owner, tag));
    end;
  end;
end;
 
function TForm1.GetTagSource(ATag: TclHtmlTag): string;
begin
  if ATag.IsClosingTag then
  begin
    Result := '</' + ATag.Name + '>';
  end else
  if ATag.IsText then
  begin
    Result := ATag.TagSource;
  end else
  begin
    Result := '<' + ATag.TagSource + '>';
  end;
end;
 
function TForm1.GetInnerHtml(AOwner, ATag: TclHtmlTag): string;
begin
  if (ATag.NextTag <> nil) and (ATag.NextTag.Owner <> AOwner) then
  begin
    if (AOwner <> ATag.Owner) then
    begin
      Result := GetTagSource(ATag);
    end else
    begin
      Result := '';
    end;
 
    Result := Result + GetInnerHtml(AOwner, ATag.NextTag);
  end else
  begin
    Result := GetTagSource(ATag);
  end;
end;

Add Feedback