NameSilo

Easiest way to add an RSS feed to a page?

SpaceshipSpaceship
Watch

Ja$on

VIP Member
Impact
62
I don't want to use anything like Joomla or Wordpress with add-ons. I just want a way to throw 1 RSS feed on 1 page and then possibly be able to modify it's look using CSS.

Is this possible? I am guessing the page would probably need to be PHP right? I just want an easy way to put up a feed directly on a page for creating mini-sites.

Any help is appreciated.

Thanks - Jason
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
If you want complete control over how it is outputted, I suggest you look into making your own PHP code to parse the RSS XML file. PHP 5 actually has native XML parsing functions, but I never really understood completely how they worked. I prefer the DOM method, using something like this:

PHP:
<?php
        
         $xmlfile = file_get_contents("http://www.rss.com/rss.xml"); //XML file to read
        
         $objDOM = new DOMDocument();
          $objDOM->loadXML($xmlfile); //make sure URL is correct
        
          $note = $objDOM->getElementsByTagName("tag1"); //main tag
          // for each note tag, parse the document and get values for
          // tasks and details tag.
        
          foreach( $note as $value )
          {
            $titles = $value->getElementsByTagName("title"); //first internal tag
            $title  = $titles->item(0)->nodeValue;
        
        
            $details = $value->getElementsByTagName("description"); //second internal tag
            $detail  = $details->item(0)->nodeValue;
        
            $urls = $value->getElementsByTagName("link"); //third internal tag
            $url  = $urls->item(0)->nodeValue;

            //and so on with internal tags
			
			
        	
            echo "$title - $details - $url"; //however you want to output format it
			
          }
        
        
        
        ?>


I found the script somewhere online (can't remember where exactly, I had this saved on my computer) so I'm just putting it out there that it's not my script.

It works well though, but I'm sure it can be optimized.
 
0
•••
So this right here alone will output the RSS into my page?
 
0
•••
yes, as long as you make the appropriate edits (like the URL to the RSS .xml file, the names of the tags you want to grab - which will take some manual reading of the pure xml file, and how you want the output to look)

example of what that script would work for (so you know my meaninng of internal tags/etc):


Code:
<rss>
<item>
    <title>TITLE GOES HERE</title>
    <description>DESCRIPTION GOES HERE</description>
    <url>www.google.com</url>
</item>
<item>
    <title>TITLE GOES HERE</title>
    <description>DESCRIPTION GOES HERE</description>
    <url>www.google.com</url>
</item>
<item>
    <title>TITLE GOES HERE</title>
    <description>DESCRIPTION GOES HERE</description>
    <url>www.google.com</url>
</item>
</rss>
 
0
•••
Ok thanks, I will try it out today.
 
0
•••
Yup, here to help.

Tell me if it worked for you.
 
0
•••

We're social

Spaceship
Domain Recover
CatchDoms
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back