user2077592
user2077592

Reputation:

SymFony DomCrawler id*='text'

I'm trying to have DomCrawler select all DIVs that IDs contain "author-"

I currently have

$list = $crawler->filter('div[id*="actor-"]')->each(function (Crawler $node, $i) { return $node->text(); }); var_dump($list);

But that doesn't return any results, is there any selector like this?

Upvotes: 0

Views: 2269

Answers (1)

xabbuh
xabbuh

Reputation: 5881

You can use contains() in your XPath like this:

$list = $crawler->filterXPath('div[contains(@id, "actor-")]')->each(function (Crawler $node, $i) {
  return $node->text();
});
var_dump($list);

Edit: From the conversation below, the XPath should be div[contains(@id, "actor-")]/b/a.

Upvotes: 1

Related Questions