[yunqa.de] Re: Parsing HTML-Tags detect HTML-Tags wrong

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Thu, 13 Mar 2008 08:44:29 +0100

Simon Schaeberle wrote:

>Function ParseHTML(vInput : WideString):WideString
>var
>    FDIHTMLParser : TDIHtmlParser;
>begin
>  FDIHTMLParser := TDIHtmlParser.Create(nil); 
>  FDIHTMLParser.ReadMethods := Read_UTF_16_LE;
>  RegisterHtmlTags;
>  FDIHTMLParser.SetSourceBufferAsStrW(vInput);
>  Result := '';
>  FDIHTMLParser.FilterHtmlTags.SetStartEnd(fiShow);
>  FDIHTMLParser.FilterText := fiShow;
>  repeat
>    while FDIHTMLParser.ParseNextPiece do
>    begin
>      case FDIHTMLParser.PieceType of
>        ptHtmlTag:
>        begin
>          Result := Result + HandleHTMLTag(FDIHTMLParser.HtmlTag);
>        end;
>        ptText:
>          { Store the multiple text pieces into a single variable. }
>          Result := Result + FDIHTMLParser.DataAsStrW;
>        end;
>     end;
>  until not FDIHTMLParser.CharOK;
>end;
>
>In HandkeHTMLTag, we would like use HTMLTag.TagID, but TagID is always 0. 

I am afraid, but this single function is not enough for me to reproduce your 
problem. For example, it does not tell me if you called the "RegisterHtmlTags" 
procedure. As written before, calling "RegisterHtmlTags" once before your 
parsing is a precondition to using the TDIHtmlTag.TagID property.

Please scetch up a small but complete project which I can compile, run, and 
test and attach it to your message as a *.zip archive. If the HTML is not 
alreadyy part of the project, please add the relevant file as well.

Ralf 

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: