PHP 原生代码生成 RSS 文档

来源:互联网 发布:常州seo姜东 编辑:程序博客网 时间:2024/06/05 06:55

<?php
  header("Content-Type:text/xml; charset=gb2312");
  echo "<?xml version=/"1.0/" encoding=/"gb2312/"?>/n";
  echo "<rss version=/"2.0/">/n";
  echo "<channel>/n";
  echo "<title><![CDATA[“十万个为什么”电脑学习网-办公自动化频道]]></title>/n";
  echo "<description><![CDATA[http://why100000.com]]></description>/n";
  echo "<link>http://why100000.com/</link>/n";
  echo "<language>zh-cn</language>/n";
  echo "<docs>WHY100000.COM Document Center</docs>/n";
  echo "<generator>Rss Generator By WWW.WHY100000.COM</generator>/n";

  $title = "PPS 有图像没声音的四个解决方法";
  $link = "http://www.why100000.com/show_answer.asp?autoid=1046&amp;Path=_oa";
  $description = "PPS 有图像没声音的四个解决方法:今天打开PPS,发现只有图像却听不到声音,其他的程序声音都是正常的,说明是PPS的问题了,那么怎么样解决这…/n";
  $author = "why100000.com";
  $pubDate = "2008-4-20 18:22:28";
  create_item($title, $link, $description, $author, $pubDate);

  echo "</channel></rss>/n";

  function create_item($title_data, $link_data, $description_data, $author_data, $pubDate_data)
  {
    echo "<item>/n";
    echo "<title><![CDATA[$title_data]]></title>/n";
    echo "<link><![CDATA[$link_data]]></link>/n";
    echo "<description><![CDATA[$description_data]]></description>/n";
    echo "<author><![CDATA[$author_data]]></author>/n";
    echo "<pubDate><![CDATA[$pubDate_data]]></pubDate>/n";
    echo "</item>/n";
  }
?>

原创粉丝点击