tags:

views:

103

answers:

1

Hi,

I'm trying to parse a RSS feed using C#, and I need to transform it with XSLT. Here's a snippet of my 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>

Using a random RSS (the corriere della serra), this renders correctly with XML Spy:

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

But when using the Microsoft .net tool (either withing my code or using the Visual Studio XSLT debugger), I get:

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

The </link> markup is not output at all. If I change "link" for "XXX", this works perfectly, but this is unfortunately not an option.

Any idea of what is happening here???

+1  A: 

Ok for those wondering, msxml doesn't close link tags while in method="html" mode. If you change the first line to

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

The above code works perfectly...

Luk
Right, that's it. I should have thought about this, but it didn't occur to me either.
Tomalak