下面的CSS选择器在jQuery中工作,所以我希望它能在QueryPath 3.0.0中工作,但它只返回一个空值:
div#caption:has(h2):contains('Product Description') div:first下面是我想让它检索的东西:
<div id="caption"><h2>Product Description</h2><div>Text I want to capture is here.</div><div>I don't want this text.</div><br clear="all" /></div>选择器怎么了?
发布于 2014-04-03 05:55:18
找到了原因。
:contains()将括号视为字符串分隔符,因此不需要字符串周围的引号。
如果将字符串包装为引号,QueryPath将查找引号。
例如,:contains('Subject')只匹配pcdata <element>'subject'</element>。
只需要去掉单引号,像:contains(Product Description)那样做。
来源:https://groups.google.com/forum/#!topic/devel-querypath/pupZjpTKyOI
https://stackoverflow.com/questions/22720146
复制相似问题