Jump to content

set up a simple rss feeds using php


Iluvatar+

Recommended Posts

Do you want to provide an rss feed to the user, or you want to use data from external RSS feeds to be displayed in your site?

 

RSS is basically xml so what you will need to do will be XML parsing or XML generation...you can try SimpleXML or DOM XML functions...

 

There is also a class I have created for xml parsing/generation/manipulation called crXml, the usage of which I have outlined in the thread

 

http://www.phpfreaks.com/forums/index.php?topic=351131.msg1657792#msg1657792

 

 

Will this work...?

 

This uses the class I mentioned in previous message....

 

$blog = array(  array('name'=>'entry 1','title'=>'title 1','type'=>'misc')  , array('name'=>'entry 2','title'=>'title 2','type'=>'misc2','anotherEntry'=>'entry content')          );

include 'crXml.php';
$crxml = new crxml;

foreach($blog as $c => $entry) {
foreach($entry as $k=>$v) {
$crxml->item[$c]->$k = $v;
}
}
echo $crxml->xml();

 

Outputs 

 

<?xml version="1.0" encoding="UTF-8"?>
<item>
  <name>entry 1</name>
  <title>title 1</title>
  <type>misc</type>
</item>
<item>
  <name>entry 2</name>
  <title>title 2</title>
  <type>misc2</type>
  <anotherEntry>entry content</anotherEntry>
</item>

 

Just replace the blog array with any content from your blog.....

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.