[英]How i can display the output of a rss feed in HTML format in a TWebBrowser?
我想在 TWebBrowser 组件中以格式化的 HTML 显示 rss 提要的 output,如果在 TWebbrowser 中加载此提要http://code.google.com/feeds/p/v8/svnchanges/basic ,这将显示内容为 XML 文件
但是如果我使用 IE 加载相同的页面
我尝试按照此问题CSS 和 TWebbrowser delphi中的建议将 css 注入加载的 IHTMLDocument2,但我仍然得到相同的结果。
问题是,我如何在 TWebbrowser 中加载 rss 提要,但像 IE 一样将 output 显示为 HTML 文档?
只是一个猜测,但您可以尝试应用以下 XSL 样式表(取自http://snippets.dzone.com/posts/show/1162并按照 cherdt 在下面评论中的建议进行修改):
<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>
到您收到的提要。 要转换文档,请参考此问题的选择答案,然后您可以尝试将生成的 XML 分配给 WebBrowser。
我猜你是将你的 WebBrowser 控件指向提要,但是使用这种方法你需要使用例如 Indy 下载提要(检查TIdHTTP
及其Get()
方法),转换它,然后显示在你的控制。
请注意,以上只是一个猜测,但我相信这是一个很好的假设。 :)
IE 正在将默认样式表和 XSL 转换应用于 RSS 提要 XML。这是 IE 的东西,而不是标准或类似的东西。
您需要自己做一些类似的事情,在页面显示之前对其进行修改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.