【发布时间】:2014-09-25 19:09:27
【问题描述】:
我正在尝试解析 RSS:http://www.mlssoccer.com/rss/en.xml。
$feed = new DOMDocument();
$feed->load($url)
$items = $feed->getElementsByTagName('channel')->item(0)->getElementsByTagName('item');
foreach($items as $key => $item)
{
$title = $item->getElementsByTagName('title')->item(0)->firstChild->nodeValue;
$pubDate = $item->getElementsByTagName('pubDate')->item(0)->firstChild->nodeValue;
$description = $item->getElementsByTagName('description')->item(0)->firstChild->nodeValue;
// do some stuff
}
问题是:我得到“$title”和“$pubDate”没有问题,但由于某种原因“$description”总是空的,里面什么都没有。这种行为的原因可能是什么以及如何解决?
【问题讨论】: