C++ XPath查询找到的QXmlQuery更改节点
我有一个html树,希望更改QXmlQuery找到的所有节点的一些属性,例如C++ XPath查询找到的QXmlQuery更改节点,c++,qt,xpath,C++,Qt,Xpath,我有一个html树,希望更改QXmlQuery找到的所有节点的一些属性,例如style 我的代码如下所示: QXmlQuery query; query.setFocus(data); query.setQuery(xpathSelector); QXmlResultItems result; if (query.isValid()) { query.evaluateTo(&result); QXmlItem item(result.next()); while
style
我的代码如下所示:
QXmlQuery query;
query.setFocus(data);
query.setQuery(xpathSelector);
QXmlResultItems result;
if (query.isValid()) {
query.evaluateTo(&result);
QXmlItem item(result.next());
while (!item.isNull()) {
if (item.isNode()) {
// alter the node here <--
}
item = result.next();
}
if (result.hasError()) {
/* Runtime error! */
}
}
QXmlQuery;
query.setFocus(数据);
setQuery(xpathSelector);
QXmlResultItems结果;
if(query.isValid()){
查询、评估和结果;
QXmlItem项(result.next());
而(!item.isNull()){
if(item.isNode()){
//在这里更改节点