Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

List the attribute names and values

File: Data.xml <para color="blue" flavor="mint" author="jm">   test </para> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:template match="para">     Color:     <xsl:value-of select="@color" />     <xsl:for-each select="@*">       attribute name:       <xsl:value-of select="name()" />       attribute value:       <xsl:value-of select="." />     </xsl:for-each>   </xsl:template>    </xsl:stylesheet> Output: <?xml version="1.0" encoding="UTF-8"?>     Color:     blue       attribute name:       color       attribute value:       blue       attribute name:       flavor       attribute value:       mint       attribute name:       author       attribute value:       jm