Non-RSS XML values

FeedOtter can also read additional, custom XML values in your RSS feed. Clients have used this to supply custom images and descriptions along with the standard RSS data fields.

This can be especially useful when building data-driven emails from job boards, news sites, and eCommerce applications.

A helpful starting point is to use the token [[ post.asArray | json_encode ]] in your loop. This will display the raw object that you can then use to access various elements using standard object / array notation as shown below.

Example 1

<item>
<title>Beautiful Painting of saharanpur</title>
<link>
https://uat.rauantiques.com/catalog/product/view/id/102845/
</link>
...
<custom_image>
<![CDATA[
https://cdn-uat.rauantiques.com/media/catalog/product/cache/1/image/265x/9df78eab33525d08d6e5fb8d27136e95/1/_/1_30-6635_1_3.png
]]>
</custom_image>
<price cost="$179,000" age="2,000 years" condition="perfect"></price>
...

Here is how to access the custom_image property in the FeedOtter post loop:

[% for post in feedotter.posts %] //standard post loop

//the post.asArray provides direct access to any xml fields in the <item> node of 
the RSS feed
[[post.asArray.custom_image.value]] 

[% endfor %]

You can also access attributes of custom elements such as the cost=”$179,000″. The post.asArray.price.attr contains all of the attributes on that node.

[% for post in feedotter.posts %] //standard post loop

//the post.asArray provides direct access to any xml fields in the <item> node of 
the RSS feed
[[post.asArray.price.attr.cost]]  // displays $179,000
[[post.AsArray.price.attr.age]] // 2,000 years
[[post.asArray.price.attr.condition]] // perfect


[% endfor %]

Example 2.

Here's another feed example with slightly different xml notation.

<item>
<title>Title Text</title>
<guid isPermaLink="false">https://link.com/article-link</guid>
<spadna:date>July 07, 2023</spadna:date>
<pubDate>Fri, 07 Jul 2023 07:50:31 PDT</pubDate>
<dna:title>Custom Title Text Here</dna:title>
<dna:pageNumber>196</dna:pageNumber>
<dna:textHeading>In Times of Illness, "Mental Health Issues"</dna:textHeading>
<description>... description text</description>
<dna:thought>... custom thought...</dna:thought>
</item>

Here the custom values are accessed slightly differently.

[[post.asArray.dna.textHeading]]
[[post.asArray.dna.thought]]

Last updated