i need to parse html like :
<div class="item"><div class="title">title 1</div><div class="date">day 1</div></div>
<div class="item"><div class="title">title 2</div><div class="date">day 2</div></div>
<div class="item"><div class="title">title 3</div><div class="date">day 3</div></div>
Actually i do something like this :
$title = $xpath->query('//div[@class="title"]//text()');
foreach ($title as $title)
{
$title = trim($title->nodeValue);
}
$date = $xpath->query('//div[@class="date"]//text()');
foreach ($date as $date)
{
$date = trim($date->nodeValue);
}
But with this i take only one item, so i looking for the proper way to get all the items in the same while.
You probably want to loop over the
itemelements, then find their respectivetitleanddatetext.» See the above example running online.