After a recent forum discussion on XML/RSS feeds from JSON i took up the challenge and thought i would write an extension to do this.
I know little about RSS feeds and this is based on a specific use/case for TMR. I have tried to make this as general purpose as possible but likely there will be some tweaks needed to make it more general purpose.
I WELCOME FEEDBACK ON IMPROVEMENTS
I hope to release a further extension soon to convert from XML to JSON as this had been a long standing feature request.
The npm can be found here:
Install like this:
This extension performs two functions.
At is most simple it converts JSON to XML in a simple fashion
So we have a query which outputs :
query: [
{
id: 1,
surname: "English",
forename: "Brian",
email: "brian@hyperbytes.co.uk"
},
{
id: 2,
surname: "Smith",
forename: "Jimmy",
email: "jimmy@smith.com"
},
{
id: 3,
surname: "Williams",
forename: "Robert",
email: "robbie@williams.com"
}
],
We pass it to the extension ignmoreing all other settings
results in an output as below (formatted for clarity in reading):
xmlfeed: {
xmldata: "<id>1</id>
<surname>English</surname>
<forename>Brian</forename>
<email>brian@hyperbytes.co.uk</email>
<id>2</id><surname>Smith</surname>
<forename>Jimmy</forename>
<email>jimmy@smith.com</email>
<id>3</id>
<surname>Williams</surname>
<forename>Robert</forename>
<email>robbie@williams.com</email>",
url: "null/null"
}
Adding an optional path and filename results in the text also being written to a file (recommend it is in public folder tree)
When specifed the output incluses the file URL
Sometimes xml data needs to be wrapped in a tag to identify different sections
In this case i use <item>
I tell the extension to insert this tag before the opening of the <id>
and close it after the </email>
tag of each record.
This results in
xmldata:
"<item>
<id>1</id>
<surname>English</surname>
<forename>Brian</forename>
<email>brian@hyperbytes.co.uk</email>
</item>
<item>
<id>2</id>
etc etc
The "trigger" to extend this XML to an rss feed is the addition of an XML declaration. Until; this is entered, thje reaming input fiel;ds are ignored.
At this point i switch to sample data supplied by TMR. This is the basis of a RSS feed
data: {
identityCompany: false,
identityPersonnel: false,
repeat: [
{
guid: "https://rigg-access.com/news/last-minute-availability-gwo-working-at-height-and-manual-handling-combined-full-module-course-in-lowestoft-24th-25th-june/1637/12233",
category: "Media Blast",
description: "Book your GWO Working at Height & Manual Handling full course today - Call now or visit our website!",
title: "Last minute availability: GWO Working at Height & Manual Handling combined full module course in Lowestoft, 24th - 25th June",
pubDate: "Thu, 19 Jun 2025 00:00:00 GMT",
link: "https://rigg-access.com/news/last-minute-availability-gwo-working-at-height-and-manual-handling-combined-full-module-course-in-lowestoft-24th-25th-june/1637/12233"
},
{
guid: "https://rigg-access.com/news/kong-backstage-kong-queedy-vs-kong-queedy-ansi-/1636/11406",
category: "Media Blast",
description: "Enjoy the video and keep following us!",
title: "🎬 KONG BACKSTAGE: Kong QUEEDY vs Kong QUEEDY ANSI ",
pubDate: "Mon, 16 Jun 2025 00:00:00 GMT",
link: "https://rigg-access.com/news/kong-backstage-kong-queedy-vs-kong-queedy-ansi-/1636/11406"
}
],
The full RSS output requried is:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Rope Access Industry News</title>
<description>Industry news supplied by the Rigg Access network</description>
<link>https://rigg-access.com</link>
<copyright>2025 rigg-access.com All rights reserved</copyright>
<pubDate>Tue, 6 May 2025 16:20:00 +0000</pubDate>
<ttl>1800</ttl>
<item>
<guid isPermaLink="false">https://rigg-access.com/Last-minute-availability-GWO-Working-at-Height-manual-Handling-combined/1637</guid>
<title>Last minute availability: GWO Working at Height & Manual Handling combined full module course in Lowestoft, 24th - 25th June</title>
<pubDate>Wed, 18 Jun 2025 23:00:00 GMT</pubDate>
<category>Media Blast</category>
<description>
<![CDATA[
Book your GWO Working at Height & Manual Handling full course today - Call now or visit our website!/>
]]>
</description>
<link>https://rigg-access.com/Last-minute-availability-GWO-Working-at-Height-manual-Handling-combined/1637</link>
</item>
<item>
<guid isPermaLink="false">https://rigg-access.com/KONG-BACKSTAGE-Kong-QUEEDY-vs-Kong-QUEEDY-ANSI/1636</guid>
<title>KONG BACKSTAGE: Kong QUEEDY vs Kong QUEEDY ANSI</title>
<pubDate>Sun, 15 Jun 2025 23:00:00 GMT</pubDate>
<category>Media Blast</category>
<description>
<![CDATA[
Enjoy the video and keep following us!
]]>
</description>
<link>https://rigg-access.com/KONG-BACKSTAGE-Kong-QUEEDY-vs-Kong-QUEEDY-ANSI/1636</link>
</item>
</channel>
</rss>
I add the XML decalrartion, This also "activates" the output of the remaining fields.
I then add the rss declaration
This adds it to the head and also adds the closing tag at the end of the output
Next we look at the headings at the top of the RSS output:
<title>Rope Access Industry News</title>
<description>Industry news supplied by the Rigg Access network</description>
<link>https://rigg-access.com</link>
<copyright>2025 rigg-access.com All rights reserved</copyright>
<pubDate>Tue, 6 May 2025 16:20:00 +0000</pubDate>
For flexibily i have added these via a panel so names and content can be added.
Lastly i noted the entire data structure was wrapped in a tag "channel"
feeddata: "<?xml version='1.0' encoding='UTF-8' ?>
<rss version='2.0'>
<channel>
CONTENT HERE
</channel>
</rss>"
I add this tag via the interface
To disable the <ttl>
section, set ttl to 0 (zero).
(DONT WORRY IF THE VALUE 0 IS NOT SAVED, THIS IS SOMETHING WAPPLER DOES BUT WILL NOT EFFECT FUNCTIONALITY)
Have fun!