Display RSS feed on website

jojoman2

New Member
Hi!

I need help displaying an RSS feed on my website which updates over time, but I only want to include those items which are in a certain category. Is there any way of doing this?
Any help would be appreciated!
 

conor

New Member
It depends on a few things. How is the rss generated? if it's a wordpress blog then I'm pretty sure you can filter by category very easily in the url. If not, you could write a PHP program which fetches the rss feed and then filters the results. Which of these cases are you looking for?
 

conor

New Member
Yeah don't think it will be possible to filter by URL with that blog.

Here's a quick PHP program which will fetch the rss feed, filter it by the $category variable and print the results:

Code:
$category = 'Insanity';

$dom = new DOMdocument( );

$success = $dom->load( 'http://circusoflamia.blogg.se/index.rss' );
if( !$success )
        die( 'failed to load url' );

$elements = $dom->getElementsByTagName( 'item' );
$items = array( );

foreach( $elements as $element ){
        $item = array( );

        if( $element->getElementsByTagName( 'category' )->item( 0 ) == $category ){
                foreach( $element->childNodes as $node )
                                $item[ $node->nodeName ] = $node->nodeValue;
             
                array_push( $items, $item );
        }
}

die( print_r( $items ) );

That's just off the top of my head but it should give you an idea on how to do this yourself
 
Top