Question

The following CSS selector works in jQuery so I was expecting it to work in QueryPath 3.0.0, but it only returns an empty value:

div#caption:has(h2):contains('Product Description') div:first

Here is what I am trying to get it to retrieve:

<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>

What is wrong with the selector?

Was it helpful?

Solution

Found the reason for this.

:contains() treats the parenthesis as string delimiters, so you don't need quotes around the string.

If you wrap the string in quotes, QueryPath looks for the quotes.

For example, :contains('Subject') only matches the pcdata <element>'subject'</element>.

Just needed to leave the single quotes off and do it like :contains(Product Description).

Source: https://groups.google.com/forum/#!topic/devel-querypath/pupZjpTKyOI

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top