I'm trying to pull the hero images for a new blog published each time and use RSS to create the content in the email. At this time all the content gets pulled in instead of the image. Can you please help what I should do it get this result. Any help will be appreciated. My code is below.

Thank you!

    <div padding:="" 15px="" 15px;="">


var @xml, @isXML, @nodes, @rowCount @i, @maxToDisplay,
Set @xml = HTTPGet("https://feeds.feedburner.com/Sonar", false, 0, @CallStatus)

if indexOf(@xml,"<channel>") > 0 then

  set @nodes = BuildRowsetFromXML(@xml,"/rss/channel/item",0)
  set @rowCount = rowcount(@nodes)


  if @rowCount > 0 then

    for @i = 1 to 1 do

      var @title
      var @description
      var @link
      var @Image

      set @nodepath = concat("/rss/channel/item[",@i,"]/")

      if rowcount(BuildRowsetFromXML(@xml,concat(@nodepath,"title"))) > 0 then
          set @title = Field(Row(BuildRowsetFromXML(@xml,concat(@nodepath,"title"),0),1),'Value')

      if rowcount(BuildRowsetFromXML(@xml,concat(@nodepath,"description"))) > 0 then
          set @description = Field(Row(BuildRowsetFromXML(@xml,concat(@nodepath,"description"),0),1),'Value')

      if rowcount(BuildRowsetFromXML(@xml,concat(@nodepath,"link"))) > 0 then
          set @link = Field(Row(BuildRowsetFromXML(@xml,concat(@nodepath,"link"),0),1),'Value')
      if rowcount(BuildRowsetFromXML(@xml,concat("//item[",@i,"]/image"),0)) > 0 then
      set @image = Field(Row(BuildRowsetFromXML(@xml,concat("//item[",@i,"]/image"),0),1),'Value')

 <img src="%%=v(@Image)=%%">

  <table width="100%" border="0" cellspacing="0" cellpadding="0">
<div><!--[if mso]>
  <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="%%=redirectto(@link)=%%" style="height:53px;v-text-anchor:middle;width:150px;" arcsize="8%" stroke="f" fillcolor="#c72b28">
      <a href="%%=redirectto(@link)=%%" style="background-color:#c72b28;border-radius:4px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:18px;font-weight:bold;line-height:53px;text-align:center;text-decoration:none;width:150px;-webkit-text-size-adjust:none;">Read Now</a>
  <!--[if mso]>
                </center><table class="button" width="30%" border="0" align="center" cellpadding="0" cellspacing="0">


    next @i


   outputline(concat("<br>no items found"))



  outputline(concat("<br>no XML found"))




I'd suggest indenting, reviewing the XML in your feed (view the source), and then testing your XPaths before even attempting to write the AMPscript to parse it.

Looks like the images are part of the content:encoded nodes:

enter image description here

Once you get the value of that node for each item, you'll need to parse out the img tag with the AMPscript string functions (indexOf, substring, and maybe as a last resort, regexmatch).

  • Super new to AMP script. So this seems very high-level to me. Can you explain this in a simpler manner what exactly do I need to focus on? – user77790 Feb 15 at 15:37
  • Parsing RSS XML is an advanced AMPscript topic, in my opinion, which is why I suggested focusing on understanding the anatomy of RSS XML and XPATH. Both of those are foundational to understanding the buildrowsetfromxml AMPscript function. – Adam Spriggs Feb 15 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.