2

I have been succesful using this code to grab content from simple RSS feed:

%%[Var @xml, @titles, @title, @links, @link, @descs, @desc, @dates,
@date, @cnt Set @xml = ContentArea("130742") Set @titles =
BuildRowsetFromXML(@xml,"//item/title",1) Set @links =
BuildRowsetFromXML(@xml,"//item/link",1) Set @descs =
BuildRowsetFromXML(@xml,"//item/description",1) Set @dates =
BuildRowsetFromXML(@xml,"//item/pubDate",1)

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

IF @rows >= 1 THEN for @cnt = 1 to @rows do Set @title =
Field(Row(@titles,@cnt), "Value") Set @link = Field(Row(@links,@cnt),
"Value") Set @desc = Field(Row(@descs,@cnt), "Value") Set @date =
Field(Row(@dates,@cnt), "Value")]%%


<div style="background-color: #F3D0A1; margin: 0.76em 0px; padding:
0.76em;"> <h1 style="font: bold 18px Helvetica,Arial,sans-serif; color:#000"><a title="%%=v(@title)=%%" alias="%%=v(@title)=%%"
href="%%=v(@link)=%%" style="color:#000;">%%=v(@title)=%%</a></h1>
<span style="font: 13px Helvetica,Arial,sans-serif; color:
#000;">%%=v(@desc)=%%</span> <br /> <span style="font: 11px Helvetica,Arial,sans-serif; color: #000;">%%=v(@date)=%%</span> </div>

%%[ NEXT @cnt ENDIF ]%%

RSS example

<rss version="2.0">
<channel>
<title>The Engineer - most recent commented stories</title>
<link>http://www.theengineer.co.uk/xmlservers/RecentlyCommentedStoriestRSS.aspx</link>
<description>http://www.theengineer.co.uk/xmlservers/RecentlyCommentedStoriestRSS.aspx</description>
<image>
<url>http://www.theengineer.co.uk/magazine/graphics/logo.png
                    </url>
<title>The Engineer</title>
<link>http://www.theengineer.co.uk</link>
</image>
<item>
<title>Vlatko Vlatkovic, head of engineering, GE Power Conversion</title>
<link>http://www.theengineer.co.uk/in-depth/interviews/vlatko-vlatkovic-head-of-engineering-ge-power-conversion/1018617.article</link>
<guid isPermaLink="true">http://www.theengineer.co.uk/in-depth/interviews/vlatko-vlatkovic-head-of-engineering-ge-power-conversion/1018617.article</guid>
<description>Good news that PV and wind power will not need subsidies soon.</description>
<pubDate>Thu, 29 May 2014 13:51 GMT</pubDate>
<displayDate>29 May 2014 1:51 pm</displayDate>
<user><name></name>
<id></id>
<anon>0</anon></user>
</item>

</channel>
</rss>

It works very well, but this XML and AMP Script example returns nothing. AMPScript the same as above exept this part

Set @titles = BuildRowsetFromXML(@xml,"//entry/title",1)
Set @links = BuildRowsetFromXML(@xml,"//entry/link",1)
Set @descs = BuildRowsetFromXML(@xml,"//entry/summary",1)
Set @dates = BuildRowsetFromXML(@xml,"//entry/author/name",1)

RSS feed

<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="http://www.w3.org/2005/Atom" xmlns:bt="http://brighttalk.com/2009/atom_extensions">
   <entry>
      <id>tag:brighttalk.com,2014:communication:108491</id>
      <updated>2014-04-07T14:47:19Z</updated>
      <title>Using ‘remarketing lists for search ads’ to target your highest value prospects</title>
      <author>
         <name>Russell Parsons, News Editor, Marketing Week</name>
      </author>
      <summary>Details coming soon. . .</summary>
      <bt:communication id="108491" />
      <bt:channel id="5932" />
      <bt:status>upcoming</bt:status>
      <bt:format>audio</bt:format>
      <bt:duration>4500</bt:duration>
      <bt:start>1401372000</bt:start>
      <bt:entryTime>1401371700</bt:entryTime>
      <bt:closeTime>1401376800</bt:closeTime>
      <bt:rating>0.0</bt:rating>
      <category scheme="keyword" term="marketing" />
      <category scheme="keyword" term="search" />
      <category scheme="keyword" term="audience" />
      <category scheme="keyword" term="management" />
      <link href="http://knowledgebank.marketingweek.co.uk/upcoming-webinars/?commid=108491" rel="alternate" type="text/html" />
      <link href="https://www.brighttalk.com/service/channel/channel/5932/communication/108491/calendar/ics" rel="related" title="calendar" type="text/calendar" />
   </entry>

   <entry>
      <id>tag:brighttalk.com,2014:communication:99541</id>
      <updated>2014-02-19T16:07:22Z</updated>
      <title>Using real time data to optimize your customer journey</title>
      <author>
         <name>Lara O'Reilly, Reporter, Marketing Week &amp; James Niehaus, VP of analytics &amp; digital strategy, Ensighten</name>
      </author>
      <summary>Marketers today want to use all their data to give richly optimized experiences to their visitors. </summary>
      <bt:communication id="99541" />
      <bt:channel id="5932" />
      <bt:status>recorded</bt:status>
      <bt:format>audio</bt:format>
      <bt:duration>3947</bt:duration>
      <bt:start>1392822000</bt:start>
      <bt:rating>3.5</bt:rating>
      <category scheme="keyword" term="Data" />
      <category scheme="keyword" term="digital" />
      <category scheme="keyword" term="'tag" />
      <category scheme="keyword" term="management'" />
      <category scheme="keyword" term="'real" />
      <category scheme="keyword" term="time'" />
      <link href="http://knowledgebank.marketingweek.co.uk/upcoming-webinars/?commid=99541" rel="alternate" type="text/html" />
      <link href="https://www.brighttalk.com/communication/99541/tn1_1.png" rel="enclosure" title="thumbnail" type="image/png" />
      <link href="https://www.brighttalk.com/communication/99541/slide1_001.png" rel="related" title="preview" type="image/png" />
   </entry>
</catalog>

Any ideas where is an issue?

1 Answer 1

1

I did some testing, and continually came up with no results as well. I then started to investigate the xPath using some online tools like XPathTool, XPath Tester, and Free Formatter.

What was odd was that //entry always returned no results. I then discovered the issue is in your XML specifically:

<catalog xmlns="http://www.w3.org/2005/Atom" xmlns:bt="http://brighttalk.com/2009/atom_extensions">

The namespace xmlns="http://www.w3.org/2005/Atom" is giving every xpath tool fits. I removed that from the XML you provided, and everything worked, including all of the online tools above, and ExactTarget.

You will need to adjust your XML output to not include that namespace.

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.