[yunqa.de] Re: DiHTMLParser: Parse and modify .aspx file

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Thu, 15 Apr 2010 19:20:53 +0200

At 17:39 15.04.2010, David Marti wrote:

>Thanks Ralf, your reply was very helpful. The only problem I have is when 
>a text on the original aspx file contains entities like &nbsp;, when I 
>write it to the destination aspx file it's showed as %amp;nbsp;

It looks like you did not register the HTML entities for decoding (reading) and 
encoding (writing). Did you?

If not, make sure to call these two procedures once before your parsing:

  { DIHtmlParser. } RegisterHtmlDecodingEntities;
  { DIUnicodeHtmlWriter. } RegisterHtmlEncodingEntities;

Ralf

>This is the code I use:
>
>    DIP:=TDIhtmlParser.Create(Nil);
>    Try
>      DIPW:=TDIHtmlWriterPlugin.Create(nil);
>      Try
>        DIPW.SetAllFilters(fiShow);
>        DIPW.FilterText := fiHide;
>        DIPW.PredefinedEntities:=[peLt,peGt,peAmp,peQuot,peNbSp];
>        DIPW.HtmlParser := DIP;
>
>        DIP.EnableASP:=True;
>        DIP.SourceFile:=OPEN.FileName;
>        DIP.FilterText:=fiShow;
>
>        While DIP.ParseNextPiece do
>        Begin
>          S:=DIP.DataAsStrW;
>          If not estaBuida(S) then
>          Begin
>            M1.Lines.Add(S);
>            // Fer la feina!
>            //S:=getVisibleASCII(S);
>          End;
>          DIPW.WriteText(S);
>        End;
>        DIPW.Writer.SaveDataToFile('c:\prova.aspx');
>      Finally
>        DIPW.Free;
>      End;
>    Finally
>      DIP.Free;
>    End;
>
>Thanks for your help.

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



Other related posts: