【问题标题】:Filter or remove item.description from an RSS feed从 RSS 提要中过滤或删除 item.description
【发布时间】:2010-10-15 12:55:25
【问题描述】:

我想在 yahoo 管道中删除 twitter 提要的 item.description 部分,但我还没有弄清楚如何去做。

显然过滤器模块会删除包含该项目的帖子,所以我一直在尝试使用正则表达式。我认为清除 item.description 字段就可以了。是否有一个正则表达式可以替换整个字符串?

基本上,目标是制作仅显示标题和发布日期的 Twitter 帖子。基本上,item.description 字段会产生冗余信息。

可以在here找到管道的副本。

【问题讨论】:

    标签: regex rss twitter yahoo-pipes


    【解决方案1】:

    理想情况下,您希望使用 XSLT 来执行此操作 - 如下所示:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="*">
            <xsl:copy>
                <xsl:copy-of select="@*" />
                <xsl:apply-templates />
            </xsl:copy>
        </xsl:template>
        <xsl:template match="//description">
            <description/>
        </xsl:template>
    </xsl:stylesheet>
    

    但是由于您使用的是 Pipes,请尝试以下正则表达式:

    &lt;description&gt;[^&lt;]*&lt;/description&gt;

    用这个:

    &lt;description/&gt;

    作为替换字符串。

    【讨论】:

    • 这很好用,我将 [^in item.description replace [^带空白
    • MattyFo,感谢您的示例,这非常有效。重新格式化您的示例以提高可读性:in item.description replace [^with(将此字段留空)。
    • 这真的符合问题的要求吗?它不会删除字段,只会将其无效。
    【解决方案2】:

    要完全删除描述节点,请在输出之前添加:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-27
      • 2011-04-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多