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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With