0
我需要解析HTML,如:獲取多個元素與DOM文檔
<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);
}
但是有了這個,我只需要一個項目,所以我在尋找正確的方式讓所有的物品在同一時間。
完美,謝謝你,我不知道「評估」:) – Tahola