I am pulling in an rss feed which contains a joke followed by a number of links to share the joke on different services. As shown below:
It may be worth noting that when I tried to copy and paste the text from this output, the links did not copy into notepad, and pasted as pictures into MS Word.
In my XSL I am using
substring-before
in an attempt to exclude these links from my output, but the only consistent character I can think to use is the<a href
from the hyperlinks, which will always be at the end. Is this possible? My first pass at it failed, is there an escape character I should include?
Perhaps I will just try to exclude the last X
characters to remove the links
Unfortunately I could not find an XML version of the feed either, my source is here: http://feeds.feedburner.com/DailyJokes-ACleanJokeEveryday?format=xml
Here is the XSL I am working with, which is currently hard-coded to break at the end of the most recent joke (my next hurdle is to iterate through this list)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:apply-templates select="//item[position() < 2]"/>
</xsl:template>
<xsl:template match="item">
<content-item>
<h1><xsl:value-of select="title"/></h1>
<p><xsl:value-of select="substring-before(description, 'mower')" disable-output-escaping="yes"/></p>
<br/><br/>
<p>"The following is here for testing purposes and will be removed"<br/><br/><xsl:value-of select="substring-after(description, 'lawn')" disable-output-escaping="yes"/></p>
<br/><br/>
</content-item>
</xsl:template>
</xsl:stylesheet>
I am rendering my output via a SharePoint 2013 RSS feed web part
In trying to view the proper XML I discovered the solution. I viewed the page source for my source URL, and in that I saw that the final characters are displayed as follows:
<title>Hunting with a wife #Joke #Humor</title><description>A hunter visited another hunter and was given a tour of his home. In the den was a stuffed lion.<br /><br />The visiting hunter asked, "when did you bag him?"<br /><br />The host said, "that was three years ago, when I went hunting with my wife."<br /><br />"What's he stuffed with," asked the visiting hunter. "My wife."<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DailyJokes-ACleanJokeEveryday?a=RT1LsKVBV3Y:0LcrJjJq2X4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DailyJokes-ACleanJokeEveryday?d=yIl2AUoC8zA" border="0"></img></a> <a href....
The point being, the a href doesnt have a
<
it uses HTML markup<
.
substring-before(description, '<a href')
works.