Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

Select= @attribute

File: Data.xml <wine grape="Cabernet Sauvignon">   <winery>Los Vascos</winery>   <year>1998</year>   <prices>     <list>13.99</list>     <discounted>11.99</discounted>     <case>143.50</case>   </prices> </wine> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:template match="prices">     parent element's grape:     <xsl:value-of select="../@grape" />   </xsl:template>    </xsl:stylesheet> Output: <?xml version="1.0" encoding="UTF-8"?>   Los Vascos   1998        parent element's grape:     Cabernet Sauvignon