Follow

XSLTGET

The XSLTGet tag allows you to retrieve and format structured data and then display it in a Template or Article.

Using XSLTGET

To get content from structured external data into your content, do the following:

  1. Create an Article containing the XSLT formatting.
  2. Create a Template or Article and define the XSLTGet tag using the correct syntax.
  3. Save the Template or Article.
  4. Preview the Template to see if the content displays.
  5. Send a test campaign to verify the content displays.

XSLTGet Syntax

The syntax for XSLTGet is as follows:

%% xsltget url="[URL]"&article_nm=[ARTICLE_NAME]&command=[COMMAND] %%

[URL]  only is enclosed in quotation marks, & between URL and each command.

If the command is improperly formated, the URL cannot be found, or some other error occurs, the command will fail.  When the Get fails, the campaign will not send messages to subscribers, and a failure notification will be delivered to the address of the user who initiated the campaign.

Commands

The [URL] is the URL to the content (html OR text), [ARTICLE_NAME] is the name of the article containing the XSLT, and [COMMAND] is one or more of the following options:

 

Command

Description

base_url

Uses the defined base URL in place of the default tracking URL.

Example: base_url=http:// sub.mydomain.com

fix_quotes

Fixes typesetter marks, such as "?" replacing special characters like curly quotes, from content defined by programs such as Word, with the correct or similar characters.  Defaults to 0, not enabled.

Example: fix_quotes=1 (enabled)

fix_relative

Fixes relative URLs in the content, adding protocol and host information to create absolute URLs.  Defaults to 0, not enabled.

Example: fix_relative=1 (enabled)

must_contain

Grabs the content if the page contains the specified text.  Otherwise, causes the campaign to fail.  Only supported by SmartGet.

Example: must_contain=[SOME_TEXT]

must_not_contain

Grabs the content if the page does not contain the specified text.  Otherwise, causes the campaign to fail.  Especially helpful to ensure the phrase "document not found" does not appear in the content. Only supported by SmartGet

Example: must_not_contain=[SOME_TEXT]

timeout

Stops attempting to pull the content if no response is received in the specified amount of time, defined in seconds. 

If a URL "times out" with "cacheget", the system will automatically refresh the cache by going out and obtaining a new copy of the content.  If it does not time out, then content is pulled from an in-memory cache. 

Defaults to 300 seconds, or five minutes.

Example: timeout=[SECONDS]

wrap

Wraps the content at the specified character length.  Wrapping occurs on word boundaries and not within quoted text or JavaScript.  It most useful for paginating plain-text.  Defaults to 0, not enabled.

Example: wrap=[NUMBER] (enabled, wrap at every [NUMBER] characters)

url

REQUIRED - Specifies the content to access.  The URL must be a valid, publicly available page that may easily be opened and examined in your web browser. 

Example: url=http:// mydomain.com/mycode.xml

article_nm REQUIRED - Specifies the name of the article containing the formatted XSLT.

Examples

The following are examples using the commands above. All commands can be combined in any order:

%%xsltget url="http:// mydomain.com/coupons.xml"&base_url=http:// sub.mydomain.com&fix_quotes=1&fix_relative=1&must_contain=My%20Company%20Name&must_not_contain=document%20not%20found&timeout=120&wrap=90%%

XSLTGet must_contain:   

%%xsltget url="http:// mydomain.com/mypage.html"&must_contain=My%20Site%20Name%%

XSLTGet must_not_contain:   

%%xsltget url="http:// mydomain.com/mypage.html"&must_not_contain=500%20Servlet%20Exception%%

Example Article and Result

The XSLTGET Tag references an article that must contain XSLT formatting data.  This article must exist in order for XSLTGET funcationality to work properly.  The XSLT in the article will tell the Template how to format called in from the XML page.

To learn more about using XSLT, go to w3schools.com XSLT Tutorial.

External XML Content

For example, if the XML is:

<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule">    <channel>       <title>Coupons of the Week</title>       <link>http:// mydomain.com/html/home</link>       <description>Big savings for your preferred products</description>       <pubDate>Mon, 20 May 2013 15:41:04 PDT</pubDate>       <item>         <category>Bakery</category>         <title>Baker's Dozen Doughnuts</title>         <link>http:// mydomain.com/html/coupons/bakery/bakersdozen.html</link>         <description>All week, get 13 doughnuts for the price of 12</description>         <expDate>01 June 2013</expDate>         <image>http:// mydomain.com/images/doughnuts.jpg</image>       </item>    </channel> </rss>

XSLT Article

To create the article:

  1. Go to Content > View Articles
  2. Click Add Article
  3. Enter a Name, for example: XSLT_coupons
  4. In the Body, add the XSLT code.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cns="http://base.google.com/cns/1.0"> <xsl:output method="html" encoding="windows-1251" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/>    <xsl:template match="/">    <html xmlns="http://www.w3.org/1999/xhtml">       <body>         <xsl:apply-templates select="rss/channel" />         <xsl:apply-templates select="rss/channel/item" />      </body>    </html>    </xsl:template>    <xsl:template match="rss/channel">       <b><a href="{link}"><xsl:value-of select="title"/></a></b><br />       <xsl:value-of select="description"/> for the week starting       <xsl:value-of select="pubDate"/><br /><br />    </xsl:template>    <xsl:template match="rss/channel/item">      <a href="{link}"><img src="{image}" width="200" /></a><br />      <b><xsl:value-of select="title"/></b><br/>      <xsl:value-of select="description"/><br /><br />    </xsl:template> </xsl:stylesheet>

  1. Click SAVE.

XSLTGet Tag

In the Template, insert the following XSLTGet tag:

%% xsltget article_nm=xslt_coupons&url="http:// mydomain.com/weeklydeals/coupons.xml"&base_url=http:// coupons.mydomain.com&must_contain=Big%20Savings %%

Result

When you Preview or Deploy the content, the result will be:

 

Coupons of the Week Big savings for your preferred products for the week starting Mon, 20 May 2013 15:41:04 PDT Baker's Dozen Doughnuts All week, get 13 doughnuts for the price of 12

*links above are examples only

 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk