我想使用这个查询(//*@id="downloadButton"/@href)和下面的代码来解析这个页面(http://www.videolan.org/vlc/):
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‘。
在页面源代码中,它们对应:
< g:plusone size="medium“href="">http://www.videolan.org">< / g:plusone>
我的问题是:有没有办法让QXmlQuery在出错后恢复?
发布于 2014-01-14 02:23:07
我直接从Qt那里得到了关于这个问题的消息。QXmlQuery不是用来解析HTML5的(见下文)。回到QWebElement...

https://stackoverflow.com/questions/21078844
复制相似问题