I Want to show the output of a rss feed in a formatted HTML in a TWebBrowser component, if a load this feed http://code.google.com/feeds/p/v8/svnchanges/basic in a TWebbrowser, this shows the content as a XML file
but if I use IE to load the same page
I tried injecting a css to the loaded IHTMLDocument2 as is suggested in this question CSS and TWebbrowser delphi but i still getting the same result.
The question is, how i can load the rss feed in TWebbrowser but showing the output as HTML document like IE does?
Just a guess, but you might try applying the following XSL stylesheet (taken from http://snippets.dzone.com/posts/show/1162 and modified as suggested by cherdt in the comments below):
<xsl:stylesheet version="1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:apply-templates select="/atom:feed/atom:head"/>
<xsl:apply-templates select="/atom:feed"/>
</xsl:template>
<xsl:template match="atom:feed/atom:head">
<h3><xsl:value-of select="atom:title"/></h3>
<xsl:if test="atom:tagline"><p><xsl:value-of select="atom:tagline"/></p></xsl:if>
<xsl:if test="atom:subtitle"><p><xsl:value-of select="atom:subtitle"/></p></xsl:if>
</xsl:template>
<xsl:template match="/atom:feed">
<h3><xsl:value-of select="atom:title"/></h3>
<xsl:if test="atom:tagline"><p><xsl:value-of select="atom:tagline"/></p></xsl:if>
<xsl:if test="atom:subtitle"><p><xsl:value-of select="atom:subtitle"/></p></xsl:if>
<ul>
<xsl:apply-templates select="atom:entry"/>
</ul>
</xsl:template>
<xsl:template match="atom:entry">
<li>
<a href="{atom:link[@rel='related']/@href}" title="{substring(atom:published, 0, 11)}"><xsl:value-of select="atom:title"/></a>
<xsl:choose>
<xsl:when test="atom:content != ''">
<p><xsl:value-of select="atom:content" disable-output-escaping="yes" /></p>
</xsl:when>
<xsl:otherwise>
<p><xsl:value-of select="atom:summary" disable-output-escaping="yes" /></p>
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:template>
</xsl:stylesheet>
To the feed you are receiving. To transform the document, refer to this question's selected answer and then you could try to assign the resulting XML to the WebBrowser.
I am guessing that you are pointing your WebBrowser control to the feed, but using this approach you would need to download the feed using, for example, Indy (check out TIdHTTP
and its Get()
method), transform it, and then display in your control.
Please note that the above is just a guess, but I believe it is a good assumption. :)
IE is applying a default style sheet and XSL transform to the RSS feed XML. This is an IE thing rather than a standard or anything like that.
You would need to do something similar yourself by modifying the page before it is displayed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With