我有一个 rss xml 文件,如下所示,标签循环了很多次。我想在标签内的url中用'm'替换字母's',所以http://farm4.staticflickr.com/3802/9593294742_a38fca47c7_s.jpg变成http://farm4.staticflickr.com/3802/ 9593294742_a38fca47c7_m.jpg
<rss xmlns:media="http://search.yahoo.com/mrss/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:creativeCommons="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html" xmlns:flickr="urn:flickr:user" version="2.0">
<channel>
<title>CCGalleria Pool</title>
<link>http://www.flickr.com/groups/ccgalleria/pool/</link>
<item>
<title>Hampton Court Palace Gardens</title>
<link>http://www.flickr.com/photos/dksesh/9593294742/in/pool-1540822@N20</link>
<description>
<p>
<a href="http://www.flickr.com/people/dksesh/">dksesh</a>
has added a photo to the pool:</p>
<p>
<a href="http://www.flickr.com/photos/dksesh/9593294742/" title="Hampton Court Palace Gardens">
<img src="http://farm4.staticflickr.com/3802/9593294742_a38fca47c7_m.jpg" width="240" height="107" alt="Hampton Court Palace Gardens"/>
</a>
</p>
</description>
<pubDate>Sun, 25 Aug 2013 10:33:09 -0700</pubDate>
<dc:date.Taken>2013-08-10T16:49:05-08:00</dc:date.Taken>
<author flickr:profile="http://www.flickr.com/people/dksesh/">nobody@flickr.com (dksesh)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/grouppool/1540822@N20/photo/9593294742</guid>
<media:content url="http://farm4.staticflickr.com/3802/9593294742_a38fca47c7_b.jpg" type="image/jpeg" height="456" width="1024"/>
<media:title>Hampton Court Palace Gardens</media:title>
<media:thumbnail url="http://farm4.staticflickr.com/3802/9593294742_a38fca47c7_s.jpg" HEIGHT="75" WIDTH="75"/>
<media:credit ROLE="photographer">dksesh</media:credit>
<creativeCommons:license>http://creativecommons.org/licenses/by-nd/2.0/deed.en_GB</creativeCommons:license>
</item>
</channel>
</rss>
我有一个类似下面的代码,但没有用。有人可以帮忙吗?非常感谢。下面新更改的代码。
<?xml version='1.0'?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:media="http://search.yahoo.com/mrss/">
<xsl:output method="html" />
<xsl:template match="/">
<xsl:for-each select="rss/channel/item">
<xsl:variable name="newurl" select="replace(media:thumbnail/@url,'_s.jpg','_m.jpg')"/>
<img src="{$newurl}" style="margin:5px 5px" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>