XSLT RSS FEED - Combine substring-before and substring-after -
my apologies in advance if question simple, can’t seem find way around issue.
i need way combine substring-before , substring-after function in xsl have start , end point within description element of rss feed.
in each description tag want extract ‘primary title’ onwards, stop reaches first <b>
tag.
i tried following xsl without success
<?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="channel"> <xsl:for-each select="item"> <xsl:value-of select=substring-after(description, 'primary title:' /> <xsl:value-of select=substring-before(description, '<b>' /> </xsl:for-each> </xsl:template> </xsl:stylesheet>
below xml working with.
<rss version="2.0"> <channel> <item> <title>article_110224_081057</title> <description> <![cdata[<div><b>description:</b>this description<b>primary title:</b>this primary title<b>second title:</b>this second title title </div> ]]> </description> </item> <item> <title>article_110224_081057</title> <description> <![cdata[<div><b>description:</b>this description<b>other title:</b>this other title<b>second title:</b>this second title titleb<b>primary title:</b>this primary title<b> more text </div> ]]> </description> </item> </channel> </rss>
if <b>
tag, won't able find using substring matching, because tags turned nodes parser. you'll able match substring if isn't tag, example because contained in cdata section (which appears case in example).
Comments
Post a Comment