1

I am trying to create a simple email that has an RSS feed pulled into it, using this site as a guide: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/rssFeedEmail.html.

I have read all the other articles associated with other people's issues and have attempted to fix the ampscript, but I have not been able to populate the area where the RSS feed; it always returns blank, no error. I have also checked the code on https://www.ampscript.io/ and am getting no errors. I am using paste HTML and the below code for the RSS feed ampscript:

%%[
Var @xml, @xml1, @titles, @title, @descs, @desc, @links, @link, @cnt
Set @xml = HTTPGet("https://www.cifinancial.com/content/ci-gam/ca/en/expert-insights/articles.rssfeed.xml", false, 0)
Set @xml = Replace(@xml,'dc:creator','dccreator')
Set @titles = BuildRowsetFromXML(@xml,"//item/title",1)
Set @descs = BuildRowsetFromXML(@xml,"//item/description",1)
Set @links = BuildRowsetFromXML(@xml,"//item/link",1)

If RowCount(@titles) > 5 THEN
   SET @rows = 5
ELSE
   SET @rows = RowCount(@titles)
ENDIF

IF @rows >= 1 THEN
   for @cnt = 1 to 5 do
       Set @title = Field(Row(@titles,@cnt),"Value")
       Set @desc = Field(Row(@descs,@cnt), "Value")
       Set @link = Field(Row(@links,@cnt), "Value")
]%%
<div style="border: 1px solid #444; background-color: #F7F7F7; margin: 0.76em 0; padding: 0.76em;">
   <h1 style="font: bold normal 1.0em Arial, Helvetica, sans-serif;"><a href="%%=RedirectTo(@link)=%%" alias="%%=v(@title)=%%" title="%%=v(@title)=%%" style="color: #000;">%%=v(@title)=%%</a></h1>
   <span style="font: normal normal 0.76em Arial, Helvetica, sans-serif; color: #444;">%%=v(@desc)=%%</span>
</div>
%%[
NEXT @cnt
ENDIF
]%%

There is a possibility that the issue is because the XML feed has special characters in the article, but my meta tag reads

<meta http-equiv="content-type" content="text/html; charset=utf-8">"

so I would think this would solve that issue... Is there is a way that ampscript can work around special characters in the XML content that is is pointing to?

1 Answer 1

2

Syntax is fine, you might just need to adjust your function to the XML structure.

The linked xml looks like this:

<rss version="2.0 [...]>
<channel>
    <title>Articles</title>
    [...]
    <item>
        <title>The Benefits of Covered Call ETFs</title>
[...]

The xml is read from the top and you tell it to go deeper into the xml tree using the "/" in the "buildRowSet" function. Each "/" is one "jump" a node deeper.

In your function, essentially just follow the indentations like so:

Set @titles = BuildRowsetFromXML(@xml,"/channel/item/title",1)

as opposed to:

/* Set @titles = BuildRowsetFromXML(@xml,"//item/title",1) */

(same for descs and links)-

following this example here: https://ampscript.guide/buildrowsetfromxml/

===

edit:

i trimmed a little and created a working example using a sample feed. (https://feedforall.com/sample.xml).

You can try this example to see how it works.

%%[
/* 

https://www.cifinancial.com/content/ci-gam/ca/en/expert-insights/articles.rssfeed.xml

https://feedforall.com/sample.xml
*/
Set @xml = HTTPGet("https://feedforall.com/sample.xml")
SET @titles = BuildRowsetFromXML(@xml,"//channel/item/title",0)

SET @rows = RowCount(@titles)
IF @rows > 5 THEN
   SET @rows = 5
ENDIF

IF @rows > 0 THEN
   FOR @i = 1 to @rows DO
       SET @title = Field(Row(@titles,@i),"Value")
]%%
<div style="border: 1px solid #444; background-color: #F7F7F7; margin: 0.76em 0; padding: 0.76em;">
   <h1 style="font: bold normal 1.0em Arial, Helvetica, sans-serif;"><a href="%%=RedirectTo(@link)=%%" alias="%%=v(@title)=%%" title="%%=v(@title)=%%" style="color: #000;">%%=v(@title)=%%</a>
  </h1>
   <span style="font: normal normal 0.76em Arial, Helvetica, sans-serif; color: #444;">%%=v(@desc)=%%</span>
</div>
%%[
    NEXT @i
ENDIF
]%%


This is copy / paste ready and shows you some content from the sample feed. However, when I replace that sample feed with yours, I get an error message that seems to lie outside of our control:

Invalid xml found in xml parameter. Function: BuildRowsetFromXML(@xml,"//channel/item/title",0). See inner exception for details An exception occurred while retrieving the XML document for string

[full xml here]

For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.

Googling for the latter part led me here: https://stackoverflow.com/questions/13854068/dtd-prohibited-in-xml-document-exception and that seems like nothing we can fix inside SFMC. At least I can safely say, I don't know how. You might want to involve support with that error message.

4
  • Thank you for the suggestion, the updated code looks like ``` %%[Var @xml, @xml1, @titles, @title, @descs, @desc, @links, @link, @cnt Set @xml = HTTPGet("cifinancial.com/content/ci-gam/ca/en/expert-insights/…) Set @xml = Replace(@xml,'content:encoded','contentencoded') Set @xml = Replace(@xml,'dc:creator','dccreator') Set @titles = BuildRowsetFromXML(@xml,"/channel/item/title",1) Set @descs = BuildRowsetFromXML(@xml,"/channel/item/description",1) Set @links = BuildRowsetFromXML(@xml,"/channel/item/link",1) ```
    – Kate
    Jun 9, 2022 at 14:37
  • But the email is still not populating...
    – Kate
    Jun 9, 2022 at 14:43
  • updated my answer Jun 9, 2022 at 16:29
  • wow, thank you looking into this, I have contacted support with this issue. Without you, I wouldn't have known where to start in describing the issue, much appreciated!
    – Kate
    Jun 9, 2022 at 18:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .