Как перемещаться в Simple HTML DOM?

День добрый. Изучаю библиотеку, не пойму как мне передвигаться по объектам. Есть html код:
<div class="CardOfferBody__twoColumnsLeft"><ul class="CardInfo"><li class="CardInfo__row CardInfo__row_year"><span class="CardInfo__cell">год выпуска</span><span class="CardInfo__cell"><a class="Link Link_color_black" href="https://auto.ru/moskva/cars/mercedes/e_klasse/2015-year/used/">2015</a></span></li><li class="CardInfo__row CardInfo__row_kmAge"><span class="CardInfo__cell">Пробег</span><span class="CardInfo__cell">78&nbsp;568&nbsp;км</span></li><li class="CardInfo__row CardInfo__row_bodytype"><span class="CardInfo__cell">Кузов</span><span class="CardInfo__cell"><a class="Link Link_color_black" href="https://auto.ru/moskva/cars/mercedes/e_klasse/used/body-sedan/">седан</a></span></li><li class="CardInfo__row CardInfo__row_color"><span class="CardInfo__cell">Цвет</span><span class="CardInfo__cell"><a class="Link Link_color_black" href="https://auto.ru/moskva/cars/mercedes/e_klasse/used/color-belyj/">белый</a></span></li><li class="CardInfo__row CardInfo__row_engine"><span class="CardInfo__cell">Двигатель</span><span class="CardInfo__cell"><div>2.0 л / 184&nbsp;л.с. / <a class="Link Link_color_black" href="https://auto.ru/moskva/cars/mercedes/e_klasse/used/engine-benzin/">Бензин</a></div></span></li><li class="CardInfo__row CardInfo__row_transportTax"><span class="CardInfo__cell">Налог</span><span class="CardInfo__cell">9&nbsp;200&nbsp;₽ / год<div class="InfoPopup InfoPopup_theme_white CardInfo__tooltip"><div class="Popup Popup-info"></div></div></span></li><li class="CardInfo__row CardInfo__row_transmission"><span class="CardInfo__cell">Коробка</span><span class="CardInfo__cell">автоматическая</span></li><li class="CardInfo__row CardInfo__row_drive"><span class="CardInfo__cell">Привод</span><span class="CardInfo__cell">задний</span></li><li class="CardInfo__row CardInfo__row_wheel"><span class="CardInfo__cell">Руль</span><span class="CardInfo__cell">Левый</span></li><li class="CardInfo__row CardInfo__row_state"><span class="CardInfo__cell">Состояние</span><span class="CardInfo__cell">Не требует ремонта</span></li><li class="CardInfo__row CardInfo__row_ownersCount"><span class="CardInfo__cell">Владельцы</span><span class="CardInfo__cell">3 или более</span></li><li class="CardInfo__row CardInfo__row_pts"><span class="CardInfo__cell">ПТС</span><span class="CardInfo__cell">Дубликат</span></li><li class="CardInfo__row CardInfo__row_customs"><span class="CardInfo__cell">Таможня</span><span class="CardInfo__cell">Растаможен</span></li><li class="CardInfo__row CardInfo__row_exchange"><span class="CardInfo__cell">Обмен</span><span class="CardInfo__cell">Рассмотрю варианты</span></li><li class="CardInfo__row CardInfo__row_vin"><span class="CardInfo__cell">VIN</span><span class="CardInfo__cell">WDD**************</span></li><li class="CardInfo__row CardInfo__row_licensePlate"><span class="CardInfo__cell">Госномер</span><span class="CardInfo__cell">******|750</span></li></ul><div class="Observer"><a class="Button Button_color_green Button_size_m Button_type_link Button_width_full VinPromoButton" role="link" href="https://auth.auto.ru/login/?r=https%3A%2F%2Fauto.ru%2Fcars%2Fused%2Fsale%2Fmercedes%2Fe_klasse%2F1098608450-580b4296%2F%3Ffrom%3Dcard-info_unauthorized&amp;from=card-info_unauthorized"><span class="Button__content"></span></a></div></div>

Вот так вытаскиваю чистый текст из блоков:
foreach($html->find('a[class=Link ListingItemTitle-module__link]') as $element) {
      echo $element->href . '<br>';
      $html = file_get_html($element->href);
      foreach($html->find('ul[class=CardInfo]') as $card) {
           var_dump( $card->plaintext ) . '<br>';
      }
    }

В итоге я получаю переменную типа string, а как например мне обратиться в цикле foreach($html->find('ul[class=CardInfo]') as $card) отдельно к каждому элементу или классу. Например отдельно хочу получить цвет:
<span class="CardInfo__cell"><a class="Link Link_color_black" href="https://auto.ru/moskva/cars/mercedes/e_klasse/used/color-belyj/">белый</a></span>

как правильно мне обратиться, чтобы я получил только этот параметр "белый" и так отдельно по каждому пройтись ?

Спасибо.
  • Вопрос задан
  • 46 просмотров
Пригласить эксперта
Ответы на вопрос 1
@Tendor
$element->find('ul[class=CardInfo]') - не работает?
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы