1

我正在尝试使用 C# 解析 RSS 提要,并且需要使用 XSLT 对其进行转换。这是我的 XSLT 的一个片段:

<xsl:output encoding="UTF-8" method="html" omit-xml-declaration="yes"/>
<xsl:template match="/">
    <xsl:apply-templates select="rss/channel/item" />
</xsl:template>
<xsl:template match="rss/channel/item">
    <item>
    <link><xsl:value-of select="normalize-space(./link)" /></link>
      </item>
</xsl:template>

使用随机 RSS(corriere della serra,这可以通过 XML Spy 正确呈现:

<item>
<link>http://www.corriere.it/este(...)2aabc.shtml</link>
</item>
<item>
<link>http://www.corriere.it/cron(...)22a-11de-bb1e-00144f02aabc.shtml</link>
</item>
...

但是当使用 Microsoft .net 工具(使用我的代码或使用 Visual Studio XSLT 调试器)时,我得到:

<item>
<link>http://www.corriere.it(...)11de-aaa2-00144f02aabc.shtml
    </item>
    <item>
    <link>http://corrieredelmezzogiorno.corriere.it/le(...)03131900.shtml
        </item>
    <item>

</link>标记根本不输出。如果我将“链接”更改为“XXX”,则效果很好,但不幸的是,这不是一个选择。

知道这里发生了什么吗???

4

1 回答 1

1

method="html"好吧,对于那些想知道的人来说,msxml 在模式下不会关闭链接标签。如果将第一行更改为

<xsl:output encoding="UTF-8" method="xml" omit-xml-declaration="yes"/>

上面的代码完美运行......

于 2009-09-25T14:12:54.340 回答