Jump to content

How to select every 2nd node in XSL


Recommended Posts

Below is an example of my code. The item tag loop through my code many times:



<title>Secret Court Palace Gardens</title>`enter code here`<link></link><description><p><a href=>aataka</a> has added a photo to the pool:</p><p><a href= title="Hampton Court Palace Gardens"><img src= width="240" height="107" alt="Secret Court Palace Gardens" /></a></p></description></item>


I need to select the url value in the 'img src' tag inside the 2nd 'a' tag. I tried something like below but didn't work. Can anyone help? Thanks very much.


<?xml version='1.0'?>

<xsl:stylesheet version="2.0" xmlns:xsl= xmlns:media=><xsl:output method="html" /><xsl:template match="/"><xsl:for-each select="rss/channel/item/description/p[2]/*"><img src="{a/@href}" style="margin:5px 5px" /></xsl:for-each></xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...