removeHtmlTags來自this post的模板可以實現您正在查找的內容。
<xsl:template name="removeHtmlTags">
<xsl:param name="html"/>
<xsl:choose>
<xsl:when test="contains($html, '<')">
<xsl:value-of select="substring-before($html, '<')"/>
<!-- Recurse through HTML -->
<xsl:call-template name="removeHtmlTags">
<xsl:with-param name="html" select="substring-after($html, '>')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$html"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
您沒有指定想要的輸出結果。這裏是一個簡單的例子,在文本前面打印每個RSS項目描述元素爲「描述X.」「」。
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="rss/channel/item/description"/>
</xsl:template>
<xsl:template match="description">
<!--This adds a label for each description: -->
Description <xsl:value-of select="position()"/>.)
<xsl:call-template name="removeHtmlTags">
<xsl:with-param name="html" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template name="removeHtmlTags">
<xsl:param name="html"/>
<xsl:choose>
<xsl:when test="contains($html, '<')">
<xsl:value-of select="substring-before($html, '<')"/>
<!-- Recurse through HTML -->
<xsl:call-template name="removeHtmlTags">
<xsl:with-param name="html" select="substring-after($html, '>')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$html"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
運行鍼對this RSS formatted search該樣式表生成以下的輸出:
Description 1.)
Ke$ha desbanca Jay-Z e Lady Gaga na parada norte-americana #adorei
Description 2.)
STR8HIPHOP: VIDEO: Just Blaze Talks Baseline Records Studio & His Work With Jay-Z:
LTD Magazine talks to Just ... http://bit.ly/7y19WU
Description 3.)
Nikon D3000 10MP $449.95 http://bit.ly/55gKZZ , DJ Hero Renegade Edition Featuring Jay-Z and Eminem $149 Amazon Now HURRY! http://bit.ly/5oW
Description 4.)
#nowplaying Empire State Of Mind , jay-z and alcia keys !
Description 5.)
#NowPlaying R. Kelly - Fiesta Remix feat_ Jay-Z http://qstat.us/z6lp
Description 6.)
50 Wants To Know Why Its Wrong For Beanie Sigel To Diss Jay-z But When The Game Disrespects Cu... http://tinyurl.com/yj5fma2
Description 7.)
Nuove Foto: Mariah, Beyonce e Jay-Z, Monica! http://bit.ly/4Em2HL
Description 8.)
NOW PLAYING: Jay-Z - Young Forever [Jay-Z + Mr Hudson] [Album Version] http://www.qmr.fm
Description 9.)
Jay-Z tops News' list of Hot New Yorkers in 2009 - http://shar.es/a91pQ
Description 10.)
VIDEO: Just Blaze Talks Baseline Records Studio & His Work With Jay-Z:
LTD Magazine talks to Just Blaze about.. http://tinyurl.com/yzx3str
Description 11.)
Download Cookin' Soul Presents: Game & Jay-Z – The RED Album | The …: Mash up posse producers Cookin' Sou.. http://bit.ly/70rDNk
Description 12.)
@Plex_Luthor you and Jay-Z! no way! lol The secret handshake ftw.
Description 13.)
Questlove and Jay-Z make a bet on the World Series (The Fightins) http://o-x.fr/9yr7
Description 14.)
Clip Jay-Z ft. Mr. Hudson - Young Forever: http://www.youtube.com/v/E1nbvplgElw http://bit.ly/4ze0If
Description 15.)
musica nova → Jay-Z ft. Alicia Keys - Empire state of mind (New York) .. mto filé
我認爲''每次的entry'標籤title'是你所需要的。 – apod 2009-12-27 14:41:24
我不確定標題是否僅僅是一個截斷的內容 - 但是已經檢查並且這是正確的,請將此添加爲答案,並且我會將其標記爲這樣。 – RoguePlanetoid 2009-12-27 15:23:40