用PHP读取RSS聚合信息
<? $rssurl = "http://soft.5x54.com/rss.php"; $bufferer = ""; $fp = fopen($rssurl,"r"); while ( !feof($fp) ) { $buffer .= fgets($fp,4096); } fclose($fp); $parser = xml_parser_create(); xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1); xml_parse_into_struct($parser,$buffer,$values,$tags); xml_parser_free($parser); $in_item = 0; foreach ($values as $value) { $tag = $value["tag"]; $type = $value["type"]; $value = $value["value"]; $tag = strtolower($tag); if ($tag == "item" && $type == "open") { $in_item = 1; } else if ($tag == "item" && $type == "close") { echo '<h3><a href="'.$link.'" target="_blank">'.$title.'</a></h3>'.$description.'('.$pubDate.')<hr size="1">'; $in_item = 0; } if ($in_item) { switch ($tag) { case "title": $title = $value; break; case "link": $link = $value; break; case "description": $description = $value; break; case "pubdate": $pubDate = gmdate("Y-m-d H:i:s",strtotime($value)); break; } } } ?>
收藏此文章 打印 更新 编辑此文章 『关闭窗口』