XSL Substring-before with HTML 个字符

XSL Substring-before with HTML characters

我正在拉取一个 RSS 提要,其中包含一个笑话,后跟一些链接以在不同的服务上分享这个笑话。如下图:

可能值得注意的是,当我尝试从该输出中复制和粘贴文本时,链接没有复制到记事本中,而是作为图片粘贴到 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?

也许我会尝试排除最后 X 个字符以删除链接

不幸的是,我也找不到 XML 版本的提要,我的来源在这里:http://feeds.feedburner.com/DailyJokes-ACleanJokeEveryday?format=xml

这是我正在使用的 XSL,它目前被硬编码为在最近的笑话结束时中断(我的下一个障碍是遍历此列表)

<?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() &lt; 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>

我正在通过 SharePoint 2013 RSS 源 Web 部件呈现我的输出

在尝试查看正确的 XML 时,我发现了解决方案。我查看了我的来源 URL 的页面来源,我看到最后的字符显示如下:

    <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.&lt;br /&gt;&lt;br /&gt;The visiting hunter asked, "when did you bag him?"&lt;br /&gt;&lt;br /&gt;The host said, "that was three years ago, when I went hunting with my wife."&lt;br /&gt;&lt;br /&gt;"What's he stuffed with," asked the visiting hunter. "My wife."&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DailyJokes-ACleanJokeEveryday?a=RT1LsKVBV3Y:0LcrJjJq2X4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DailyJokes-ACleanJokeEveryday?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href....

The point being, the a href doesnt have a < it uses HTML markup &lt;.

substring-before(description, '&lt;a href') works.