我需要像这样解析html:
<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>
其实我做这样的事情:
$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);
}
但是有了这个我只拿一件物品,所以我正在寻找正确的方法来同时获得所有物品。