Jump to content

[resolved] test value of attribute


rvdokkum

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>

Link to comment
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 comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...