Jump to content

[SOLVED] How to parse RSS feeds by php code ? Cannot set header file type (xml)


adrianTNT

Recommended Posts

Hello, I want to generate a feed file dynamically inside a .php file, but in my browser it looks like a plain file even if the source file contains the right tags, I simplified it to this code (attached), is the header info incorrect or why does the browser read it like a plain file?

 

<?php header ("content-type: text/xml");?>
<?php echo html_entity_decode('<?xml version="1.0" encoding="UTF-8" ?>');?> 
<rss VERSION="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
   <channel>
       <item>
       <title>Pong</title> 
       <link>http://www.site.com/flash/games/pong_1327.html</link> 
       <description>Flash Ping-Pong game.Just my version of one of the first games.</description> 
       </item>
       <item>
       <title>RSS reader</title> 
       <link>http://www.site.com/flash/web_applications_and_data/rss_reader_1326.html</link> 
       <description>RSS reader in AS2, uses shared object to save the address if u want</description> 
       </item>
   </channel>
</rss>

I can make it physically save an XML file but I prefer to show the xml contents in the php file.

Any ideas?

Thanks.

Link to comment
Share on other sites

Your code works fine for me.

Did you add an empty line or space before sending the header?

It works now.

No spaces when I tested but today it works fine, it was a cache issue.

 

You want it to show the contents of the file, like a feed?  I have experience with this as I created a generator that would create an xml feed from the contents of the news table in my database.

Yes, something like that, but the problem now was the header info to tell browsers to treat it like an XML file, I will now see if it works to dinamically generate the tags, this part should not be a problem.

Thank you both for your time.

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.