Ver Mensaje Individual
  #8  
Antiguo 30-03-2015
elguille elguille is offline
Miembro
 
Registrado: ene 2005
Posts: 114
Reputación: 20
elguille Va por buen camino
El codigo descrito en mi caso tenia un comportamiento errático en tiempo de proceso al ejecutarse muchas veces, llegando a estar 20 segundos para una sola transformación en cambio este me ha ido perfecto y rápido...
Código Delphi [-]
uses
MSHTML,
SHDocVw,
ActiveX;

function GetPlainText(Const Html: string): string;
var
DummyWebBrowser: TWebBrowser;
Document       : IHtmlDocument2;
DummyVar       : Variant;
begin
   Result := '';
   DummyWebBrowser := TWebBrowser.Create(nil);
   try
     //open an blank page to create a IHtmlDocument2 instance
     DummyWebBrowser.Navigate('about:blank');
     Document := DummyWebBrowser.Document as IHtmlDocument2; 
     if (Assigned(Document)) then //Check the Document
     begin
       DummyVar      := VarArrayCreate([0, 0], varVariant); //Create a variant array to write the html code to the  IHtmlDocument2
       DummyVar[0]   := Html; //assign the html code to the variant array
       Document.Write(PSafeArray(TVarData(DummyVar).VArray)); //set the html in the document
       Document.Close;
       Result :=(Document.body as IHTMLBodyElement).createTextRange.text;//get the plain text
     end;
   finally
     DummyWebBrowser.Free;
   end;
end;
Responder Con Cita