2

I'm trying to build a custom RSS feed from scratch, and want to include an image that I can pull out using Mailchimp.

So my current RSS item looks like this:

<item>
    <link><?php echo get_permalink($beforeAfter->procedureID); ?></link>
    <media:content url="<?php echo get_bloginfo('url').'/wp-content/uploads/before-after/md/'.$beforeAfter->after_img;?>" type="image/jpg" />
    <?php rss_enclosure(); ?>
    <?php do_action('rss2_item'); ?>
</item>

But when I view it, I get the error:

error on line 15 at column 124: Namespace prefix media on content is not defined

If I remove the <media:content> line, the error goes away. Any ideas why the error is appearing, and why it won't read it correctly?

Here are some links I'm using for reference: http://www.rssboard.org/media-rss#media-content http://kb.mailchimp.com/merge-tags/rss-blog/feedblock-rss-merge-tags

Lee
  • 4,187
  • 6
  • 25
  • 71

1 Answers1

16

See http://www.rssboard.org/media-rss#namespace-declaration:

The namespace for Media RSS is defined to be http://search.yahoo.com/mrss/

For example:

<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">

Include the xmlns:media declaration on one of the parent elements of the <media:content/> element.

Community
  • 1
  • 1
Joe
  • 29,416
  • 12
  • 68
  • 88
  • Thanks, you saved my life! I had no idea why this error was coming up... – Ethan Oct 05 '17 at 07:48
  • It looks as if the media namespace definition at yahoo is no longer in place: wget http://search.yahoo.com/mrss/ --2018-02-16 19:34:19-- http://search.yahoo.com/mrss/ Resolving search.yahoo.com... 63.250.200.63 Connecting to search.yahoo.com|63.250.200.63|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://video.search.yahoo.com/mrss [following] --2018-02-16 19:34:19-- http://video.search.yahoo.com/mrss Resolving video.search.yahoo.com... 63.250.200.63 Reusing existing connection to search.yahoo.com:80. HTTP request sent, awaiting response... 404 – PlayGod Feb 17 '18 at 00:35
  • "no longer in place"; see https://stackoverflow.com/questions/27613891/must-an-xml-namespace-name-uri-be-retrievable – Joe Jul 19 '21 at 11:41