1
给定xpath_query
和xml_attribute
或xml_node
,我想知道该属性或节点是否与查询匹配。pugixml:找出xpath是否匹配特定的节点/属性
我可以评估查询到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;
}
然而,这似乎有点昂贵。有更便宜的方法吗?