How do I check the content type?

The OnLoadParser event is fired immediately before the ParsePointer, ParseStream, ParseFile and ParseWideString methods.

Use the Abort variable to skip any undesired content type.

Example:
The following accepts all content types except UTF16-LE without a byte order mark (BOM)

procedure TForm1.ATagParserLoadParser(Sender: TObject; ContentType: TContentType;
  var Abort: Boolean);
begin
  Case ContentType Of
    ctUTF16LE :
      ShowMessage('Content type is 16bit Unicode - little endian (with BOM)'
);
    ctUTF16LE_NO_BOM :
      Begin
        ShowMessage('UTF16LE is not allowed'
);
        Abort := True;  
      End;
    ctUTF8 :
      ShowMessage('Content type is 8bit Unicode - (with BOM)'
);
    ctANSI :
      ShowMessage('Content type is ANSI'
);
  End;
end;




Copyright 2000 - 2006 John E McTaggart - All rights reserved worldwide