How can I get source code of page thru WebBrowser Control (ActiveX InternetExplorer)?
I have an xml document "foo.xml".
var
Web: TWebBrowser;
begin
...
Web.Navigate("foo.xml");
// How can I get source code thru WebBrower control<----
...
end;
How can I get source code of page thru WebBrowser Control (ActiveX InternetExplorer)?
I have an xml document "foo.xml".
var
Web: TWebBrowser;
begin
...
Web.Navigate("foo.xml");
// How can I get source code thru WebBrower control<----
...
end;
I thought this would be easy but it seems it might have been forgotten. You can easily do it with a TidHTTP control though.
MyPage := IdHTTP1.Get('www.google.com');
I know its not what you want but might help.
In the DocumentCompleted event, look at the DocumentText
property of the WebBrowser control. It should have the complete text of the loaded page.
IHTMLDocument2(Web.Document).Body.InnerHTML;
This should return the source of the page.
Another method which works well is to use Synapse. Use the synapse call HttpGet to retrieve your initial resource (which gives you the source code) then manipulate as needed.
Another option would be to use the EmbeddedWB component which exposes MANY more properties and features of the web browser than the standard Delphi component does and still fits your requirement of doing it within the web browser.
To access the entire HTML of the page through your WebBrowser control use:
Web.Document.All[0].OutterHtml;
private void btnTest_Click(object sender, EventArgs e)
{
wbMain.Navigate("foo.xml");
wbMain.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(testing);
}
private void testing(Object sender, WebBrowserDocumentCompletedEventArgs e)
{
test = wbMain.DocumentText;
}
I know this is a little late but this works for me. wbMain is the WebBrowser Object.