Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以使用 QWebkit 的 XPath 和 Qt 类(可能还有其他标准或 Qt 类)来解析 HTML(HTML/HTML5,而不是 XHTML)页面,而无需使用 tidy 之类的任何外部实用程序?
非常感谢!
不,很明显。XPath 用于格式良好的 XML,而 HTML 不是(除了您明确排除的 XHTML)。
要访问 QtWebkit 页面的 DOM 树,您必须使用 QtWebkit 的QWebElementapi。
QWebElement
您可以使用以下方式访问文档元素
QWebElement QWebView::page()->mainFrame()->documentElement();