Get original HTML source as well as current DOM

Add-in Express™ Support Service
That's what is more important than anything else

Get original HTML source as well as current DOM
 
Todd Price




Posts: 14
Joined: 2014-08-13
One of the tasks our add-in performs is to store away both the original HTML source and the DOM version of the HTML as well. The DOM can be quite a bit larger if a user is on a web page that does a lot of XHR's to pull in data and add DOM nodes. Our code looks like this:


            currentSnapshot.Dom = this.HTMLDocument.body.innerHTML;
            currentSnapshot.Html = this.HTMLDocumentText;


Occasionally we will get one of these exceptions:


COMException: Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))


...or...


NotSupportedException: Exception from HRESULT: 0x800A01B6


And the stack trace shows:


System.RuntimeType:200 in "ForwardCallToInvokeMember"
mshtml.DispHTMLDocument:-1 in "get_body"


Is there a better way of getting these two artifacts (source and DOM HTML)?

Thanks for your help.
Posted 15 Dec, 2014 11:22:25 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello Todd,

This can occur if the HTML of that page isn't 100% correct. Also, I suppose this may occur if you execute that code in a background thread.

Todd Price writes:
Is there a better way of getting these two artifacts (source and DOM HTML)?


I don't know. Wrapping the code line a try/catch seems to be an obvious minimum.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 16 Dec, 2014 07:55:04 Top