0

I have a $brick which is an instance of Crawler and this is how $brick->html() starts:

  <div>
          <div>testplain 1</div>
  </div>

I am fishing out the div containing testplain 1 with:

  $content = $brick
    ->children()->first()
    ->children()->first();

but this is not nice. I know I could drop first() but that would make it even more confusing IMO. Is there a way to say first <div> of the first <div> in a nicer way with DOMCrawler?

chx
  • 11,270
  • 7
  • 55
  • 129
  • If I remember properly you can use xpath in domcrowler. Can you do something like "//div[.//ancestor::div]" or $brick->filterXPath('//div/div')->html() – A Paul Dec 25 '20 at 18:38
  • "A double slash " // " means any descendant node of the current node in the HTML tree which matches the locator." that certainly won't do. I am unsure whether `filterXpath('div/div')` would be anchored to the beginning or not. – chx Dec 25 '20 at 20:00

0 Answers0