0
DomDocumentを使用してRSSフィードを取得しましたが、奇妙な問題が発生しました。 http://rss.slashdot.org/Slashdot/slashdotのようないくつかのRSSフィードを取得すればうまく動作します。しかし、私が解析しようとしているRSSフィードは、私に問題を与えています:http://www.ryanhache.com/feedDOMDocument :: getElementsByTagNameはPHPでチャンネルを取得しません
これは、チャネルタグを見つけてループすることができないようです。私が継承した関数は以下の通りで、RSS_Retrieve($ url)で呼び出されます。私はこれらの機能に欠けているものは何ですか、または私が引っ張っているフィードに何か問題がありますか?
function RSS_Tags($item, $type)
{
$y = array();
$tnl = $item->getElementsByTagName("title");
$tnl = $tnl->item(0);
$title = $tnl->firstChild->textContent;
$tnl = $item->getElementsByTagName("link");
$tnl = $tnl->item(0);
$link = $tnl->firstChild->textContent;
$tnl = $item->getElementsByTagName("pubDate");
$tnl = $tnl->item(0);
$date = $tnl->firstChild->textContent;
$tnl = $item->getElementsByTagName("description");
$tnl = $tnl->item(0);
$description = $tnl->firstChild->textContent;
$y["title"] = $title;
$y["link"] = $link;
$y["date"] = $date;
$y["description"] = $description;
$y["type"] = $type;
return $y;
}
function RSS_Channel($channel)
{
global $RSS_Content;
$items = $channel->getElementsByTagName("item");
// Processing channel
$y = RSS_Tags($channel, 0); // get description of channel, type 0
array_push($RSS_Content, $y);
// Processing articles
foreach($items as $item)
{
$y = RSS_Tags($item, 1); // get description of article, type 1
array_push($RSS_Content, $y);
}
}
function RSS_Retrieve($url)
{
global $RSS_Content;
$doc = new DOMDocument();
$doc->load($url);
$channels = $doc->getElementsByTagName("channel");
$RSS_Content = array();
foreach($channels as $channel)
{
RSS_Channel($channel);
}
}
「http:// www.ryanhace.com/feed」のURLは404のようですか? –
バールはURLのスペルを間違えています:http://www.ryanhache.com/feed – Jeff
ここにいるようです。あなたの実際の出力と期待される出力は何ですか? –