program imglist; { Example of extracting info from HTML - Get the values of all "<IMG SRC=" tags.} {$IFDEF FPC}{$H+}{$MODE OBJFPC}{$ENDIF} {$IFDEF WIN32}{$APPTYPE CONSOLE}{$ENDIF} uses tidyobj; procedure AttrProc(const info:tNodeInfo; name:pChar; value:pChar; user_data:pointer); begin if (string(name) = 'src') and ( value <> nil ) then begin WriteLn(value); inc(LongInt(user_data^)); end; end; procedure NodeProc(const info:tNodeInfo; user_data:pointer); begin ForEachAttr(info, @AttrProc, user_data); end; var ImageCount:uint; Tidy:tTidy; begin if ( ParamCount > 0 ) then begin Tidy:=tTidy.Create(nil); Tidy.ForceOutput:=True; if ( Tidy.ParseFile(ParamStr(1)) <> '' ) then begin ImageCount:=0; ForEachTag(Tidy.Handle, Tidy.RootNode, TidyTag_IMG, @NodeProc, @ImageCount); WriteLn('Found ', ImageCount, ' images.'); end else WriteLn('Unable to parse input file "', ParamStr(1), '"'); Tidy.Free; end else WriteLn('usage: imglist <filename>'); end.