How do I parse links from a file?
This is a very common question and very, very simple with ATagParser.
The simplest way is to use the OnAttribute event and watch for the HREF attribute name and ParentTagHash. Drop an instance of ATagParser on a form.
Include in the Uses clause
ComplexFilters settings
Elements settings
Double click the OnAttribute event and add the following code:
procedure TForm1.ATagParserAttribute(Sender: TObject;
Attribute: TAttributeElement; var Abort: Boolean);
var
AttrID, TagID: Integer;
begin
AttrID := HTML_Ex.FindAttributeID(Attribute.Hash);
If Index = AID_HREF Then
Begin
TagID := HTML_Ex.FindTagID(Attribute.ParentTagHash);
If TagID = TID_A Then
// Attribute.Value holds the actual link
End;
end;
It's just that simple.
Copyright 2000 - 2006 John E McTaggart - All rights reserved worldwide