Search code examples
phpxmlrssgoogle-news

Google News RSS Feed -


Trying to get just a text description out of this good news feed, i dont' want the html but i can't find a common way to split it out..

http://news.google.co.uk/news?pz=1&cf=all&ned=uk&hl=en&as_scoring=r&as_maxm=4&q=web+design&as_qdr=a&as_drrb=q&as_mind=6&as_minm=3&cf=all&as_maxd=5&output=rss


Solution

  • If you know how to get the HTML data from the right XML-element (<description> in this case) you can just strip all HTML with PHP's strip_tags

    This seems to work like you want it:

    $news = simplexml_load_file('http://news.google.co.uk/news?pz=1&cf=all&ned=uk&hl=en&as_scoring=r&as_maxm=4&q=web+design&as_qdr=a&as_drrb=q&as_mind=6&as_minm=3&cf=all&as_maxd=5&output=rss');
    
    foreach($news->channel->item as $item) {
        echo $item->title . "\n";
        echo strip_tags($item->description) ."\n";
    }