R
Robson Felix
Folks,
I've spent the last 3 hours fighting to get the EXACT content as being
displayed in "View Source" (as we can easily do by just accessing the
property DocumentText in the WebBrowser object). Unfortunatelly, there is no
easy way of doing this when you directly access the activex object. If you
cast axWebBrowser.Document to any HTML interface on mshtl, by any properties
you try to get the HTML source code from, the result is not consistent with
what is being presented. Sometimes tags are missing, sometimes tags are not
properly quoted, etc.The way I found to do this was:
Implement a FileSystemWatcher in the form with the following properties
..Path =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache),
"Content.IE5");
..Filter = "*.htm";
..IncludeSubdirectories = true;
by implementing the events Created and Changed I change a global variable on
my form with the content of FileSystemEventArgs.FullPath.
Each and everytime the browser navigates to a page, a file is generated
there with the content (when we click View Source in the browser, it just
opens the file that's already there).
Then I created a method that read the entire content of this file and I use
it wherever I need. It works perfectly.
I just thought of sharing this with the community since I didn't find
anything on this matter.
Best regards,
Robson
I've spent the last 3 hours fighting to get the EXACT content as being
displayed in "View Source" (as we can easily do by just accessing the
property DocumentText in the WebBrowser object). Unfortunatelly, there is no
easy way of doing this when you directly access the activex object. If you
cast axWebBrowser.Document to any HTML interface on mshtl, by any properties
you try to get the HTML source code from, the result is not consistent with
what is being presented. Sometimes tags are missing, sometimes tags are not
properly quoted, etc.The way I found to do this was:
Implement a FileSystemWatcher in the form with the following properties
..Path =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache),
"Content.IE5");
..Filter = "*.htm";
..IncludeSubdirectories = true;
by implementing the events Created and Changed I change a global variable on
my form with the content of FileSystemEventArgs.FullPath.
Each and everytime the browser navigates to a page, a file is generated
there with the content (when we click View Source in the browser, it just
opens the file that's already there).
Then I created a method that read the entire content of this file and I use
it wherever I need. It works perfectly.
I just thought of sharing this with the community since I didn't find
anything on this matter.
Best regards,
Robson