lxml 不支持 xpath 上的多个属性过滤器

lxml not supports multiple attributes filter on xpath

我想 select 使用 xpath

具有多个属性的节点

我的问题有解决方法吗?

node.xpath('.//td[@colspan=6 @class="mbw"]')

  File "lxml.etree.pyx", line 1507, in lxml.etree._Element.xpath (src/lxml/lxml.etree.c:52198)
  File "xpath.pxi", line 307, in lxml.etree.XPathElementEvaluator.__call__ (src/lxml/lxml.etree.c:152124)
  File "xpath.pxi", line 227, in lxml.etree._XPathEvaluatorBase._handle_result (src/lxml/lxml.etree.c:151097)
  File "xpath.pxi", line 212, in lxml.etree._XPathEvaluatorBase._raise_eval_error (src/lxml/lxml.etree.c:150896)
lxml.etree.XPathEvalError: Invalid predicate

您的 xpath 表达式缺少用于组合每个属性标准的逻辑运算符(andor),例如:

node.xpath('.//td[@colspan=6 and @class="mbw"]')