0

I want to find every <h2> and <h3> tags which are a question. So I need to check if the headline contains a question mark ?.

At the moment my code looks like this:

$query = '//*[contains("h2 h3", name())]';

I saw in this answer, that there is some kind of selector. But I'm not sure how to use something like this with my h2 and h3 selectors:

$query = '//*[contains(text(), '?')]';

Here I found this:

$query = '//h2/*[contains(text(), "?")]';

But I get an error in my function. You can see the function here. I'm not sure if that's related.

Cray
  • 5,307
  • 11
  • 70
  • 166

1 Answers1

0

I found a solution:

$query = "//h2[contains(., '?')] | //h3[contains(., '?')]";
Cray
  • 5,307
  • 11
  • 70
  • 166