【发布时间】:2012-08-16 15:40:05
【问题描述】:
给定一个xpath_query 和一个xml_attribute 或xml_node,我想知道查询是否会匹配该属性或节点。
我可以将查询评估为xpath_node_set,然后检查节点是否在内部,如下所示:
bool match(const pugi::xpath_query& query, const pugi::xml_node& node)
{
for (const auto& child : query.evaluate_node_set(node.parent()))
{
if (child.node() == node)
return true;
}
return false;
}
但是,这似乎有点贵。有没有更便宜的方法?
【问题讨论】: