2012-04-07 50 views
8

我想显示RSS提要的格式化HTML在TWebBrowser组件的输出,如果负载此饲料http://code.google.com/feeds/p/v8/svnchanges/basic在TWebbrowser,这显示内容为XML文件如何在TWebBrowser中以HTML格式显示RSS源的输出?

enter image description here

但如果我用IE浏览器加载在同一页

enter image description here

我试图注入的CSS加载的IHTMLDocument2作为建议在这个问题上CSS and TWebbrowser delphi,但我仍然得到同样的结果。

问题是,我如何加载TWebbrowser的RSS饲料,但显示输出为HTML文件,如IE浏览器呢?

回答

5

只是一个猜测,但你可以尝试采用以下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> 

为了您收到的饲料。要转换文档,请参阅this question's selected answer,然后您可以尝试将生成的XML分配给WebBrowser。

我在猜测您正在将WebBrowser控件指向Feed,但使用此方法时,您需要使用Indy(检查出TIdHTTP及其Get()方法)下载Feed,然后对其进行转换,然后显示在你的控制。

请注意,以上只是一个猜测,但我相信这是一个很好的假设。 :)

2

IE正在将默认样式表和XSL转换应用于RSS源XML。这是一个IE的东西,而不是一个标准或类似的东西。

您需要通过在页面显示前修改页面来完成类似的操作。