J
J
John Bjornsen2018-08-23 13:24:17
PHP
John Bjornsen, 2018-08-23 13:24:17

Why does phpQuery only find one child element?

There is a certain page and from it I want to pull out all the li.spisok elements from this block:
5b7e8a30c157b689416717.png
Here is the code with which I am trying to get these elements:

require 'phpQuery.php';

$url = 'https://svmed.spb.ru/spisok/';
$file = file_get_contents($url);

$document = phpQuery::newDocument($file);
$li = $document->find('ul.container > li.spisok');
echo $li;

As a result of this code, only the first li element is found. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-08-23
@Bjornsen

$all_li= $document->find('li.spisok');
foreach ($all_li as $li) {
    echo $li;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question