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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...