How To Remove HTML Elements From Drupal 7 Feed

In this article you will learn how to style RSS feed in Drupal 7 (not sure, but most bellow written should apply to Drupal 8 as well)

I'm using RSS feeds to power up e-mail newsletters, see How To Sync Drupal RSS Feed to Mailchimp, and everything would be fine, except I had to stop automated email marketing because of amazon affiliate links included in feeds, which is against Amazon Associates TOS

If you are sending out RSS feeds via email and you are not concerned breaching some rules with links included, this article is not for you, but if you are on Drupal, using Amazon Associates for product reviews and sending out e-mail newsletters powered by RSS, keep reading.

Solution turned out much easier than I thought at start.

Visit your content type, under Manage Display scroll down to Custom Display settings and enable RSS feed

Custom Display Settings for Drupal 7 Content types

Custom Display Settings for Drupal 7 Content types

Next under RSS display settings manage fields you would like to keep, and set body to plain text (or some other predefined text format)

Rss Display settings for Drupal

Rss Display settings for Drupal

For powering Mailchimp newsletters I'm using a custom built RSS view

Add a Feed view to default content view (you can use some of your existing views, for example frontpage, or create a new content view with a feed display)

Feed settings:

  • Path: rss.xml

Format:

  • Format: RSS Feed
  • Show: Content: RSS

Now make sure you change content display settings to RSS you enabled at content type manage display section (see above). Save your view and here you go, you just stripped out all html elements from your feed. Now, if you want to keep some html elements like line breaks or paragraphs and most probably images, you should go to text format settings and enable custom html elements for plain text. 

As I'm using several RSS feeds, with just one stripping out <a href> attributes, I created a custom Text format especially for these kind of feeds - Amazon RSS Feed.