[Your IP: 23.20.25.122]
Logowanie

Język: PL EN

KySoft Systemy Informatyczne


sitemap

PHP/HTML tips & tricks

email-validator
html-entities
http-build-str
inline-sms-orange
inline-youtube
mathjax-equations
rss-howto
skype-hidden-emots
syntax-highlight
text-highlight
world-flags
(currently only in english)
How to create RSS channel on my web?
It is simple...

1. in HEAD section of HTML place link to rss file
  <link rel="alternate" type="application/rss+xml" title="KySoft RSS" href="myrss.xml" />

2. create XML file 'myrss.xml' - as referred above
<?xml version="1.0" encoding="iso-8859-2"?>
<rss version="2.0">
<channel>
	<title>Channel title</title>
	<link>http://kysoft.pl</link>
	<language>pl</language>
	<description>channel description</description>
	<lastBuildDate>DATE</lastBuildDate>
	<pubDate>DATE</pubDate>

	<item>
	<title>News Item 1</title>
	<author>krzydyn</author>
	<link>http://kysoft.pl?id=1</link>
	<pubDate>DATE</pubDate>
	<description>Item description</description>
	</item>
</channel>
</rss>  
Note: DATE must be in format: Fri, 01 Jun 2012 15:03:56 +0200

It is little more complex (but flexible) to generate from php...

1. in HEAD section of HTML place link to myrss.php file
  <link rel="alternate" type="application/rss+xml" title="KySoft RSS" href="myrss.php" />

2. create PHP file 'myrss.php' - as referred above
<?
header("Content-type: application/rss+xml");
echo "<?xml version=\"1.0\" encoding=\"iso-8859-2\"?>\n";
$rows=getRows();//call some function to retrieve rows and store result in variable
// assumig that each row has fields: id, title, author, createtime, contents
$build=time();
$pub=time();
?>
<rss version="2.0">
<channel>
	<title>Channel title</title>
	<link>http://kysoft.pl</link>
	<language>pl</language>
	<description>channel description</description>
	<lastBuildDate><?echo date("r",$build)?></lastBuildDate>
	<pubDate><?echo date("r",$build)?></pubDate>

<?for ($i=0; $i < sizeof($rows); ++$i){$r=$row[$i];?>
	<item>
	<title><?$r["title"]?></title>
	<author><?$r["author"]?></author>
	<link>http://kysoft.pl?id=<?$r["id"]?></link>
	<pubDate><?echo date("r",$r["createtime"])?></pubDate>
	<description><?$r["contents"]?></description>
	</item>
<?}?>
</channel>
</rss>  

Dodaj komentarz