views:

300

answers:

1

Hi, 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?

+2  A: 

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.

Martin Honnen