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

  • From: "David Marti" <dmarti@xxxxxxxxxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Thu, 15 Apr 2010 17:39:04 +0200

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;

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.

-----Original Message-----
From: Delphi Inspiration <delphi@xxxxxxxx>
To: yunqa@xxxxxxxxxxxxx
Date: Thu, 15 Apr 2010 14:16:53 +0200
Subject: [yunqa.de] Re: DiHTMLParser: Parse and modify .aspx file

> At 13:35 15.04.2010, David Marti wrote:
> 
> >I need to parse several aspx files. With your component is very very
> easy, 
> >but I don't now how to change some parsed data (text) to finally save
> a new 
> >aspx file.
> 
> There are a couple of demo projects which show how to modify HTML
> files:
> 
>   Demos\DIHtmlParser_Console\DIHtmlParser_Replace_Text_Chunks.dpr
> 
>   Demos\DIHtmlParser_Console\DIHtmlParser_Modify_Src_Links.dpr
> 
>   Demos\DIHtmlParser_Console\DIHtmlParser_Insert_Body_Event.dpr
> 
> To change *.aspx files you can use the same method, except that you
> have to adjust the filter settings according to your needs.
> 
> If this does not help, please get back with a more detailed description
> of what exactly you want to achieve.
> 
> Ralf  
> 
> _______________________________________________
> Delphi Inspiration mailing list
> yunqa@xxxxxxxxxxxxx
> //www.freelists.org/list/yunqa
> 
> 
> 


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



Other related posts: