Answer the question
In order to leave comments, you need to log in
How to search in a previously found xpath element?
There is a page with a tabular layout where the characters are located.
Code for selecting the entire table.
//h2[text()="Characters & Voice Actors"]/following-sibling::table[position() < last()]//tr/td[contains(@class, "borderClass bgColor") and 2 = position()]
//tr/td[contains(@class, "borderClass bgColor") and 2 = position()]
div/small
/a
//h2[text()="Characters & Voice Actors"]/following-sibling::table[position() < last()]//tr/td[contains(@class, "borderClass bgColor") and 2 = position()]/div/small/text()
//h2[text()="Characters & Voice Actors"]/following-sibling::table[position() < last()]//tr/td[contains(@class, "borderClass bgColor") and 2 = position()]/a
$extracted = $anime->getFilterXPath('//h2[text()="Characters & Voice Actors"]/following-sibling::table[position() < last()]');
echo iterator_count($extracted); // 39
$extracted2 = $anime->getFilterXPath('//tr/td[contains(@class, "borderClass bgColor") and 2 = position()]', $extracted);
echo iterator_count($extracted2); //68
$extracted3 = $anime->getFilterXPath('//h2[text()="Characters & Voice Actors"]/following-sibling::table[position() < last()]//tr/td[contains(@class, "borderClass bgColor") and 2 = position()]');
echo iterator_count($extracted3); //39
Answer the question
In order to leave comments, you need to log in
DOMNode is passed to the query method as the second parameter, inside which something needs to be found. The documentation has a good example php.net/manual/en/domxpath.query.php
one.
How to use prefetch results?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question