我想使用此查询解析此页面(http://www.videolan.org/vlc/) (// * [@ id =“downloadButton”] / @ href)和此代码:
QXmlResultItems out;
QXmlQuery xpath(QXmlQuery::XQuery10);
xpath.setQuery("doc('http://www.videolan.org/vlc/')//*[@id=\"downloadButton\"]/@href");
xpath.evaluateTo(&out);
QXmlItem item(out.next());
while (!item.isNull()) {
qDebug()<<item.toAtomicValue().toString();
item = out.next();
}
但我得到的只是一条消息说:
错误http://www.videolan.org/vlc/,第151行第65列:未声明命名空间前缀'g'。
对应于页面源:
&LT; g:plusone size =“medium”href =“http://www.videolan.org”&gt;&lt; / g:plusone&gt;
我的问题是:错误后有没有办法让QXmlQuery恢复?
答案 0 :(得分:0)
我直接从Qt获得有关此问题的消息。 QXmlQuery不是为了解析HTML5(见下文)。回到QWebElement ......