我正在尝试从 rss 提要中获取链接,但这样做时出现以下错误
Warning: Invalid argument supplied for foreach() in /home/sss/public_html/radiorss/feedcrawler.php on line 1
1
下面是我正在运行以获取值的代码。
<?php
include 'xml_regex.php';
include 'simple_html_dom.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'www.newsonair.nic.in/NSD.asp');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xml = curl_exec($ch);
curl_close($ch);
foreach($item as $item) {
echo $item->title.'<br />';
echo $item->pubDate.'<br />';
echo $item->link.'<br />';
echo $item->description.'<br />';
echo $item->enclosure.'<br />';
}
?>
请帮助我知道我错在哪里。提前致谢