1

Im trying to pull RSS feed into my email. I want to pull in the <content:encoded> as the full description and the image. I added "Set @xml = Replace(@xml1,'content:encoded','contentencoded')". I am using this:

   %%[ var @xml, @xml1, @nodes, @rowCount Set @xml = HTTPGet("https://www.tpcc.org/_assets/feeds/blog.php?blogname=daily-bible-reading", false, 0)
Set @xml = Replace(@xml1,'content:encoded','contentencoded') if indexOf(@xml,"<channel>") > 0 then

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


  if @rowCount > 1 then



    for @i = 1 to @rowCount do

      var @title
      var @description
      var @link


      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')
      endif

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

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



      ]%%


       <div>
<h3 style="font-family: 'SalesforceSansBold', Helvetica, Arial, sans-serif; color:#333333; font-size:18px;mso-line-height-rule: exactly;line-height:26px;margin: 0 0 5px 0;font-weight:bold;text-align: left" class="font_normal"><a href="%%=RedirectTo(@link)=%%" alias="%%=v(@title)=%%" title="%%=v(@title)=%%" style="color:#009ddc; text-decoration:none">%%=v(@title)=%%</a></h1>
<span style="font-family: 'SalesforceSansRegular', Helvetica, Arial, sans-serif; color:#333333; font-size:18px;mso-line-height-rule: exactly;line-height:24px;margin: 0 0 20px 0;text-align: left">%%=v(@description)=%%</span><br><br>
<a style="font-family: 'SalesforceSansRegular', Helvetica, Arial, sans-serif; color:#009ddc; font-size:18px;mso-line-height-rule: exactly;line-height:24px;margin: 0 0 20px 0;text-align: left" href="%%=redirectto(@link)=%%">Read More...</a><br><br>

</div>
  <hr>
      %%[

    next @i

  else

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

  endif

else

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

endif

]%%

I am getting "no XML found"

This may be a double post.

  • Also i am building this in Marketing Cloud, I would only like the first item, how to i pull only one post? – Menkelly Mar 15 '19 at 17:32
1

You can change the criteria of your loop to stop at 1 instead of @rowCount. That will pull only the first item.

%%[

set @xml = HTTPGet("https://www.tpcc.org/_assets/feeds/blog.php?blogname=daily-bible-reading", false, 0)
set @nodes = BuildRowsetFromXML(@xml,"/rss/channel/item",0)
set @rowCount = rowcount(@nodes)

if @rowCount > 0 then
    for @i = 1 to 1 do
      var @title, @description, @link

      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')
      endif

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

      if rowcount(BuildRowsetFromXML(@xml,concat(@nodepath,"link"))) > 0 then
          set @link = Field(Row(BuildRowsetFromXML(@xml,concat(@nodepath,"link"),0),1),'Value')
      endif
  next @i
endif
]%%

<table border="1" cellpadding="1" cellspacing="1">  
  <tr><td>@description</td><td>%%=v(@description)=%%</td></tr>
  <tr><td>@i</td><td>%%=v(@i)=%%</td></tr>
  <tr><td>@link</td><td>%%=v(@link)=%%</td></tr>
  <tr><td>@nodepath</td><td>%%=v(@nodepath)=%%</td></tr>
  <tr><td>@nodes</td><td>%%=v(@nodes)=%%</td></tr>
  <tr><td>@rowCount</td><td>%%=v(@rowCount)=%%</td></tr>
  <tr><td>@title</td><td>%%=v(@title)=%%</td></tr>
  <tr><td>@xml</td><td>%%=v(@xml)=%%</td></tr>
</table>

Or you can eliminate the loop:

%%[

set @xml = HTTPGet("https://www.tpcc.org/_assets/feeds/blog.php?blogname=daily-bible-reading", false, 0)
set @nodes = BuildRowsetFromXML(@xml,"/rss/channel/item",0)
set @rowCount = rowcount(@nodes)

if @rowCount > 0 then

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

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

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

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

endif
]%%
| improve this answer | |
  • Thanks Jake! I added this and it works great! Any idea how i can pull just the first <content:encoded></content:encoded> and <enclosure url=""/> I am pulling in all of it right now. @jake314159 – Menkelly Mar 17 '19 at 0:30

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.