XML Feeds

XML Feeds

We had a client say he needs a certain feature, namely embedding content from an XML feed into his emails. Literally within 5 business days we were at the third iteration cycle, with stable code and feature set rich enough to call it “production ready”.

This is what we do for nearly 20 years now – prompt response to client business needs. Come join our family! Ping joe@volomp.com for more info.

Examples

OK, let’s get to it, here’s the syntax:

[XML_FEED_BEGIN url="<URL>" <options>]
 <item contents dressed in your html>
 [XML_FEED_END]

 

Here’s a simple example with some HTML:

<table>
 [XML_FEED_BEGIN url="http://rss.cnn.com/rss/edition.rss" cached="True" count="5"]
 <tr>
 <td>
 <a href="%%$xmlfeed.item.link%%">
 <img src="%%$xmlfeed.item.image%%" width="100" height="100"/>
 </a>
 </td>
 <td>
 <strong>%%$xmlfeed.item.title%%</strong><br />
 <p>%%$xmlfeed.item.description%%</p>
 </td>
 </tr>
 [XML_FEED_END]
 </table>

Here’s what it looks like:

Options

In the source you see the URL, and you see the count option set to 5, which means “pull 5 items from the feed, and if there’s less than 5 items in the current feed then repeat them over, I want 5 dammit”. Here are all the options (defaults are shown here, values can be: true, false, yes, no, 1, 0 (it’s all case insensitive)):

count=“5”
  • The number 5 is the number of items you want to embed. If the feed is shorter than the desired count Volo will simply repeat items, from the top.
allow_empty=“true”
  • True means: allow the feed to be empty, just ignore it.
  • False means: abort the mailing preparation if the feed is empty, make that a show stopper.
cached=“True”
  • True means: read the feed only once, cache it and then keep reusing that.
  • False means: no cache, meaning re-read the feed for each email we are preparing. Caution, a 1MM drop means you are pulling info from that feed a million times over within 2 minutes, might get you banned by the feed provider. False makes sense only if you are pulling items from your own feed, and you give out different items each time (effectively this is a way to populate your emails from an external database).
require_image=“false”
  • False means: an item with missing image is accepted, no problem.
  • True means: skip any items with image missing.

Please note, when the “cached” option is left at default (True) Volo will read the entire feed once, cache it, and then assign “count” sized chunks to each email while moving down the feed (and starting from the top once the end of the feed is reached, in a round-robin fashion). This is the best and the most elegant way to have some current and pertinent data in your emails, from so many feeds out there. For instance, everything on a well known forum is a feed..

If, on the other hand,  you were looking for a way to insert data from your own database into  the emails, you’ve got:

  1. Volo tags (means the data is already in the database on your Volo)
  2. xAPI DynQueue injecting (here’s a Volo API Cookbook on that)
  3. This little xml feed method

 

Feed contents

The actual texts from the feed are as follows:

  • xmlfeed.item.title
  • xmlfeed.item.link
  • xmlfeed.item.description
  • xmlfeed.item.pubdate
  • xmlfeed.item.guid
  • xmlfeed.item.content
  • xmlfeed.item.image

I believe not every feed has all of these, you’ll see what the feed you are going for offers.

 

OK, as always, feedback welcome at joe@volomp.com, let us know!