XSLT - showing HTML tags from RSS feeds

Associate
Joined
19 Jun 2003
Posts
1,680
Location
West Yorks, UK
Hi all,
I'm just experimenting with XSLT for the first time today. I'm trying to take an RSS feed, and display it to the screen - I've got that bit working fine.

However, i'm falling over when it comes to displaying HTML that is embedded in the RSS feed properly. For example, the description of the article has <strong></strong> tags in. This seems to be being converted into HTML entities. How can I stop this, and display it as HTML?

Cheers,
Matt
 
Associate
Joined
15 May 2006
Posts
224
Hi,

Can you catch the <strong></strong> element in a template? You can then output something else instead of these tags e.g

Code:
<xsl:template match='strong'>
    <xsl:value-of select="."/>
</template>

Or something like that anyway.

Jim
 
Associate
Joined
1 Feb 2006
Posts
1,868
Location
Reading
CDATA means what is inside the braces will be ignored by the parser, basically it is used to wrap an elements text that has illegal characters such as & and <.

The feed has cdata'd the <strong> tags so that the rss output your end will echo them out and display the text in bold, rather than interpretting the strong tags as xml elements. If you don't want the text to be bold you will have to strip out the strong tags from the cdata elements.

Hope this clarifies.
 
Associate
Joined
1 Feb 2006
Posts
1,868
Location
Reading
That one will yield the same result as the first.

Instead of using CDATA to escape illegal characters it has replaced the "<" and ">" part of html tags with legal equivelants "&lt;" (less than) and "&gt;". When this is rendered they will be replaced with < and > respectively.
 
Back
Top Bottom