错误后QXmlQuery恢复

时间:2014-01-12 18:52:07

标签: xml qt

我想使用此查询解析此页面(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恢复?

1 个答案:

答案 0 :(得分:0)

我直接从Qt获得有关此问题的消息。 QXmlQuery不是为了解析HTML5(见下文)。回到QWebElement ......

Conversation with Qt