I am trying to pull posts from my RSS feed into an email via Ampscript. I have the code correct and it's pulling the right number of stories. I just want to change the number of stories the script returns to only show items that have been published in the last 7 days.
Here is what I have working now. It just returns the last 5 stories.
%%[Var @xml, @imaged, @titles, @title, @descs, @desc, @links, @link, @cnt
Set @xml = HTTPGet("https://rss.com/feed")
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 @rows do
Set @title = Field(Row(@titles,@cnt),"Value")
Set @desc = Field(Row(@descs,@cnt), "Value")
Set @link = Field(Row(@links,@cnt), "Value") ]%%
<head>
<style type="text/css">
.auto-style1 {
text-align: left;
}
.auto-style2 {
color: #000000;
}
.auto-style3 {
font-size: 14px;
}
.auto-style4 {
text-align: left;
font-size: 20px;
}
</style>
</head>
<div style="border: 1px solid #444; background-color: #F7F7F7; margin: 0.76em 0; padding: 0.76em;">
<h1 style="font-style: normal; font-variant: normal; font-weight: bold; line-height: normal; font-family: Arial, Helvetica, sans-serif;" class="auto-style4"><a href="%%=RedirectTo(@link)=%%" alias="%%=v(@title)="%%" title="%%=v(@title)=%% style="color: #000;">
<span class="auto-style2">%%=v(@title)=%%</span></a></h1>
<div class="auto-style1">
<span style="color: #444; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-family: Arial, Helvetica, sans-serif;" class="auto-style3">%%=v(@desc)=%%</span>
</div>
</div>
%%[
NEXT @cnt
ENDIF
]%%