Jump to content

[resolved] test value of attribute

Recommended Posts

i like to test the value of an attributehow do i check if the value of attribute type="audio"this is what my xml looks like

<tumblr><posts><post type="audio"><audio-caption>....

this i my attempt that is not working

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"> <h2>Blog</h2>	<table> 	  <xsl:for-each select="tumblr/posts/post">	  <tr>		<td>		   <xsl:if test="tumblr/posts/post/@type='audio'">			 <xsl:text>audio node</xsl:text> 		   </xsl:if>		</td>	  </tr>	  </xsl:for-each>	</table></xsl:template></xsl:stylesheet>

Edited by Remko van Dokkum
Link to post
Share on other sites
Well your for-each changes the context node so inside it to check the 'type' attribute you simply need
<xsl:if test="@type = 'audio'">...</xsl:if>

thanksi see i also got my quotes messed up at the end of audio'all working
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...