2012-04-07 47 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的東西,而不是一個標準或類似的東西。

您需要通過在頁面顯示前修改頁面來完成類似的操作。