当前位置: 动力学知识库 > 问答 > 编程问答 >

python 3.x - lxml not supports multiple attributes filter on xpath

问题描述:

I want to select nodes with multiple attributes using xpath

is there any workaround for my problem ?

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

网友答案:

Your xpath expression is missing logical operator (and or or) for combining each attribute criteria, for example :

node.xpath('.//td[@colspan=6 and @class="mbw"]')
分享给朋友:
您可能感兴趣的文章:
随机阅读: