Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6751981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:59:29+00:00 2026-05-26T12:59:29+00:00

I’m having some problems with parsing RSS feeds with Zend_Feed_Reader, specifically when a RSS

  • 0

I’m having some problems with parsing RSS feeds with Zend_Feed_Reader, specifically when a RSS namespace is being used.

The feed I’m trying to parse is the BBC News feed (http://feeds.bbci.co.uk/news/rss.xml) which includes the following:

<item>
<media:thumbnail width="66" height="49" url="http://news.bbcimg.co.uk/media/images/55800000/jpg/_55800088_013076641-1.jpg"/>
<media:thumbnail width="144" height="81" url="http://news.bbcimg.co.uk/media/images/55807000/jpg/_55807247_013074606-1.jpg"/> 
</item>

The code I’m using to parse the other items in <item> is as such:

$feed = Zend_Feed_Reader::import('http://feeds.bbci.co.uk/news/rss.xml');
foreach($feed as $item)
{
    echo $item->getTitle();
    echo $item->getDescription();
    // etc
}

However, using $item->getMedia(), $item->getMedia('thumbnail'), $item->{'media:thumbnail'} or $item->{'media:thumbnail'}() doesn’t work.

I also tried writing my own extension (using this as a guide):

class Zend_Feed_Reader_Extension_Media_Entry extends Zend_Feed_Reader_Extension_EntryAbstract
{
    public function getThumbnail()
    {
        if(isset($this->_data['thumbnail']))
            return $this->_data['thumbnail'];

        $thumbnail = $this->_xpath->evaluate(
            'string(' . $this->getXpathPrefix() . '/media:thumbnail)'
        );

        if(!$thumbnail)
            $thumbnail = null;

        $this->_data['thumbnail'] = $thumbnail;

        return $this->_data['thumbnail'];
    }

    protected function _registerNamespaces()
    {
        $this->_xpath->registerNamespace('media', 'http://search.yahoo.com/mrss');
    }
}

And then doing all the appropriate extension registering (Zend_Feed_Reader::registerExtension('media');) returns a null when running $item->getThumbnail().

Does anyone have any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:59:29+00:00Added an answer on May 26, 2026 at 12:59 pm

    I also did follow the guide at Zend.com and found out that there is a problem with the first code block, the arguments for Zend_Feed_Reader::addPrefixPath are in incorrect order, and has to be like this:

    if(!Zend_Feed_Reader::isRegistered('JungleBooks')) {
        Zend_Feed_Reader::addPrefixPath(
            'My_FeedReader_Extension', '/path/to/My/FeedReader/Extension'
        );
        Zend_Feed_Reader::registerExtension('JungleBooks');
    }
    

    I assume you registered your extension this way?

    That done, and with a custom extension I continued.
    Using the complete example from Zend.com just gave me an empty string.
    After trying some different notations for getting to the namespace like double colons ::, brackets [] and even @ symbols I almost gave up.

    And then something popped into mind; what if I try to fetch my XPath without a string() wrap, and so I did (I used your code to make it even clearer):

    class Zend_Feed_Reader_Extension_Media_Entry 
        extends Zend_Feed_Reader_Extension_EntryAbstract
    {
        public function getThumbnails()
        {
            if(isset($this->_data['thumbnails'])){
                return $this->_data['thumbnails'];
            }
    
            $thumbnail_list = $this->_xpath->evaluate(
                $this->getXpathPrefix() . '/media:thumbnail'
            );
            $thumbnails = array();
    
            // According to your XML sample there are multiple thumbnails per item, so we're looping through them and adding them to a simple array
            foreach($thumbnail_list as $_thumbnail_element){
                array_push($thumbnails, array(
                    'url'    => $_thumbnail_element->getAttribute('url'),
                    'width'  => $_thumbnail_element->getAttribute('width'),
                    'height' => $_thumbnail_element->getAttribute('height'),
                ));
            }
    
            if(!count($thumbnails)){
                $thumbnails = null;
            }
    
            $this->_data['thumbnails'] = $thumbnails;
    
            return $this->_data['thumbnails'];
        }
    
        protected function _registerNamespaces()
        {
            $this->_xpath->registerNamespace('media', 'http://search.yahoo.com/mrss');
        }
    }
    

    And voila, there are your thumbnails.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Specifically, suppose I start with the string string =hello \'i am \' me And

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.