Navigation and WebBrowser control

帅比萌擦擦* 提交于 2019-12-23 08:47:29

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/2535252/navigation-and-webbrowser-control

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!