MSXML无法正确关闭 XSLT转换期间标签(msxml fails to correctly

2019-10-17 16:38发布

我试图解析使用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(在晚邮报塞拉 ) ,这个正确呈现与XML间谍:

<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工具(无论是withing我的代码或使用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”,这完美的作品,但是这是不幸的是没有一个选项。

任何想法,这里发生了什么的???

Answer 1:

好为那些想知道,MSXML没有密切联系的标签,而在method="html"模式。 如果更改第一行

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

上面的代码工作完全...



文章来源: msxml fails to correctly close tags during XSLT transformation
标签: .net xslt msxml