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

 

 

Link to comment
Share on other sites

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.....

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.