PHP读取feed
摘要PHP读取feed,用PHP自带的simplexml系列函数实现1.只读取标题<?php $xml=simplexml_load_file('http://www.site.com/rss.xml'); foreach($xml->chan…
PHP读取feed,用PHP自带的simplexml系列函数实现
1.只读取标题
<?php
$xml=simplexml_load_file('http://www.site.com/rss.xml');
foreach($xml->channel->item as $item){
echo '<a href="'.$item->link.'">';
echo $item->title;
echo '</a>';
echo '<br/>';
echo '<br/>';
}
?>
2.读取标题和摘要
<?php
$xml=simplexml_load_file('http://www.site.com/rss.xml');
foreach($xml->channel->item as $item){
echo '<a href="'.$item->link.'">';
echo $item->title;
echo '</a>';
echo '<br/>';
$des=str_replace(' ','',str_replace(' ','',strip_tags($item->description)));
$des=str_replace("\n",'',$des);
$des=str_replace("\r",'',$des);
echo $des;
echo '<br/>';
}
?>
作者:迷你日志
来源:PHP读取feed
免责声明:本站内容仅为知识科普与信息整理,不构成建议或承诺。
666啊
1aa啊