Link to home
Start Free TrialLog in
Avatar of lavitz
lavitzFlag for Poland

asked on

WebBrowser outerHTML and '??????'

Hi,

I have problem with getting source from webbrowser. Some charakters are replaced with question marks. Iam using Delphi 7

Avatar of Mahdi78
Mahdi78
Flag of Algeria image

Try this

Memo1.Text := WebBrowser1.OleObject.Document.documentElement.innerHTML;
Avatar of jimyX
jimyX

What is the code the you are using ?

Here is the right way to do that:
http://delphi.about.com/od/adptips2005/qt/webbrowserhtml.htm

uses mshtml;

var
    iall : IHTMLElement;
begin
   if Assigned(WebBrowser1.Document) then
   begin
     iall := (WebBrowser1.Document AS IHTMLDocument2).body;

     while iall.parentElement <> nil do
     begin
       iall := iall.parentElement;
     end;
     memo1.Text := iall.outerHTML;
   end;
end;

Open in new window

Avatar of lavitz

ASKER

I have made simple test on new project.
WebBrowser navigates prepared html file, and show it in tmemo.
Code is like jimyX: described.
And unfortunately i still have ????? in memo.

There is nothing  i could do wrong.

html file that i have loaded have charset=utf-8 and characters iam wrote  was cyrillic.
Set your memo font to "Arial Unicode MS".
Avatar of lavitz

ASKER

didnt work.

html code (in place of ??????? is cyrillic, i dont know why EE dosnt save it)
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>
¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿<br>
¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿<br>
¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿gfd<br>
</body></html>

Open in new window


delphi code
 
procedure TForm1.Button2Click(Sender: TObject);
var
    iall : IHTMLElement;
begin
   if Assigned(WebBrowser1.Document) then
   begin
     iall := (WebBrowser1.Document AS IHTMLDocument2).body;

     while iall.parentElement <> nil do
     begin
       iall := iall.parentElement;
     end;
     memo1.Text := iall.outerHTML;
   end;
end;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jimyX
jimyX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lavitz

ASKER

It works with different components(tnt)