2

We would like to populate a product grid pulled from an product category RSS feed. Below is code pulled from the help doc for using RSS feed in email.

Within the grid we need to include product's (title, image & link) for product positions 1-9 from the RSS feed (see link inside AMPScript).

From the "help" code, we've also added image + inserted a dynamic date statement %%=Format(Now(),"MM-dd-yyyy")=%% to update tracking parameters.

Content Area

%%before; httpget; 1 "http://www.nastygal.com/feed/clothes"%%

AMPScript

%%[

Var @xml, @titles, @title, @descs, @desc, @links, @link, @cnt

/* This line specifies the content area from which the RSS content will be pulled for the email message. */
Set @xml = ContentAreaByName("my contents\newarrivals_clothes_9") 

Set @titles = BuildRowsetFromXML(@xml,"//item/title",1)
Set @links = BuildRowsetFromXML(@xml,"//item/link",1)
Set @images = BuildRowsetFromXML(@xml,"//item/img",1)

If RowCount(@titles) > 9 THEN
     SET @rows = 9
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")
        Set @image = Field(Row(@images,@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 ]%%

QUESTION

Based on what we have, will the AMPScript understand appropriate values to pull in from RSS?

Did we insert @image correctly?

0

1 Answer 1

0

No. The XPath values in your BuildRowSetFromXML() functions don't match your RSS feed.

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
   <author>
      <name>Nasty Gal</name>
   </author>
   <id>Nasty Gal: clothes</id>
   <title>clothes</title>
   <updated>2015-08-05T02:33:12+00:00</updated>
   <entry>
      <id>$158.00</id>
      <link href="http://www.nastygal.com/clothes/nasty-gal-hear-me-rawr-moto-jacket" />
      <summary>http://i.ngimg.com/resources/nastygal/images/products/processed/56657.0.browse-l.jpg</summary>
      <title>Nasty Gal Hear Me Rawr Moto Jacket</title>
      <updated>2015-08-05T02:33:12+00:00</updated>
      <dc:date>2015-08-05T02:33:12+00:00</dc:date>
   </entry>
   <entry>
      <id>$200.00</id>
      <link href="http://www.nastygal.com/clothes/nasty-gal-easy-rider-leather-skirt" />
      <summary>http://i.ngimg.com/resources/nastygal/images/products/processed/54770.0.browse-l.jpg</summary>
      <title>Nasty Gal Easy Rider Leather Skirt</title>
      <updated>2015-08-05T02:33:12+00:00</updated>
      <dc:date>2015-08-05T02:33:12+00:00</dc:date>
   </entry>
</feed>

If you want the links, titles and images, you'll need to reference them via XPATH with //entry/title, //entry/link and //entry/summary:

%%[

/* other AMPScript */

Set @titles = BuildRowsetFromXML(@xml,"//entry/title",1)
Set @links = BuildRowsetFromXML(@xml,"//entry/link",1)
Set @images = BuildRowsetFromXML(@xml,"//entry/summary",1)

/* other AMPScript*/
]%%

You'll probably want to output the image in your for loop, also:

<div style="border: 1px solid #444; background-color: #F7F7F7; margin: 0.76em 0; padding: 0.76em;">

    <a href="%%=RedirectTo(@link)=%%" alias="%%=v(@title)="%%" title="%%=v(@title)=%%>
        <img style="display:block;" src="%%=v(@image)=%%"/>
    </a>

    <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>
3
  • Thank you! That makes sense. Still unsure for what is supposed to be stored in the email message template vs. in the content area referenced in amp? Commented Aug 5, 2015 at 18:49
  • right now we have all the ampscript (listed above) inside the content area. In the email template it references the content area's name only (<custom type="content" name="newarrivals_clothes_9">). It throws an error for all the amp fields when we try to test send. Commented Aug 5, 2015 at 18:59
  • That's how I'd configure the template and email. But I'd recommend not using a content area for the RSS feed -- just use the set @xml = httpget("http://www.nastygal.com/feed/clothes") Commented Aug 5, 2015 at 19:02

You must log in to answer this question.

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