Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation and WebBrowser control

Tags:

browser

c#

xpath

Can i use XPAth expressions to navigate through DOM elements in WebBrowser control? May be attaching javascript code and use document.evaluate function is right way?

Can another activeX browser component(firefox,webkit.net) help me to solve my task?

like image 794
Neir0 Avatar asked Mar 29 '10 00:03

Neir0


People also ask

What is WebBrowser control?

The WebBrowser control provides a managed wrapper for the WebBrowser ActiveX control. The managed wrapper lets you display Web pages in your Windows Forms client applications.

How do you use browser control?

To do so, right-click on the WebBrowser control, and select Properties. This action launches the Properties window. Feel free to set any properties you like. The Url property represents the web page a WebBrowser displays.

How do I add WebBrowser control to Windows app?

We need to add a web browser control to our form window. Go to [ ToolBox > Common Controls > WebBrowser ], now drag & drop the web browser control to the form, like below. Now one more thing we need to add into the form is statusStrip . This will show the page load progress while user put URLs and hit the Go button.


1 Answers

The Microsoft WebBrowser control is a managed wrapper around Microsoft's COM web browser control, as far as I understand it. So under the hood it is the same rendering and DOM implementation that IE uses, called MSHTML. As that does not support XPath against its HTML DOM, does not support the 'evaluate' method (which is part of W3C DOM Level 3 XPath) I don't see a way to perform XPath queries against a HTML document loaded in Microsoft's WebBrowser control. Whether there are third party .NET web browser controls based on other browsers that support XPath against a HTML DOM I don't know.

If you want to use .NET to perform XPath against a HTML document then there is the HTML agility pack. That is independent of the WebBrowser control however so you can't use it to navigate a HTML document loaded in a WebBrowser control, instead you would work with a separate implementation.

like image 100
Martin Honnen Avatar answered Oct 10 '22 14:10

Martin Honnen