Paul Maker
asked on
IHTMLDocument2
Hi
I have written an IE BHO that uses the IHTMLDocument2 interface to alter the HTML, i need to be able to get the complete modified source including all the tags <!DOCTYPE....<HTML>....</H TML>. the get_body->get_innerHTML only gives me the <BODY>.....</BODY> section, thats no good i need the lot.
I either need to have it as a sting (BSTR) or be able to save it to a file.
i have already seen the few questions on here that suggest get_body, please dont suggest them... it dont work how i want it to.
Ta
Paul
I have written an IE BHO that uses the IHTMLDocument2 interface to alter the HTML, i need to be able to get the complete modified source including all the tags <!DOCTYPE....<HTML>....</H
I either need to have it as a sting (BSTR) or be able to save it to a file.
i have already seen the few questions on here that suggest get_body, please dont suggest them... it dont work how i want it to.
Ta
Paul
I'm pretty sure that'll work for IHTMLDocument2 ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ToString actually does that? I voiced a thought about that in an earlier question but never actually tried it.
hmmm, i might double-check..... it was a while ago that i used it ;)
I'll get back to ya.
I'll get back to ya.
ASKER
i have solved this by getting the IPersistFile interface from the IHTMLDocument2 object...
thanx anyway
thanx anyway
ASKER
sorry about the delay - since the update of the look & feel of EE the flash, adverts and animated gifs anoy slightly.
none of the solutions proposed here are really suitable because of the way IE alters the raw HTML in its object model. anyway i will split the points.
none of the solutions proposed here are really suitable because of the way IE alters the raw HTML in its object model. anyway i will split the points.
QI your IHTMLDocument2 to get an IHTMLDocument3 interface (hopefully) you'll get an IHTMLDocument3 interface back and from this you should be able to get what you want.
Here's the source (note: it's in the most basic form, i.e. no ATL etc. and for brevity all error handling has been removed).
IHTMLDocument3 pHTMLDoc3;
pHTMLDoc2->QueryInterface(
IHTMLElement* pDocElem;
pHTMLDoc3->get_DocumentEle
pHTMLDoc3->Release();
BSTR bstrHTML;
pDocElem->get_OuterHTML(&b
pDocElem->Release();
I've not tested this C++ code but converted it to C# (as I've been using the browser recently in C#) and it seems to produce everything <html> to </html>.