I have an xml of the following format
<catalog>
<cd>
<title>CD name</title>
</cd>
</catalog>
I can use xslt to get the element value using the following:
<xsl:template match="/">
<xsl:for-each select="catalog/cd">
<xsl:value-of select="title" />
</xsl:for-each>
But, I am trying to figure out the xsl code to read the xml in the following format:
<catalog>
<cd title="CD name"/>
</catalog>
How do I do this? And if anyone can post some xslt tutorial link, it will be much appreciated.
This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="cd">
<xsl:value-of select="concat(@title, '
')"/>
</xsl:template>
</xsl:stylesheet>
when applied on this XML document:
<catalog>
<cd title="CD1 name"/>
<cd title="CD2 name"/>
<cd title="CD3 name"/>
</catalog>
produces the wanted result:
CD1 name
CD2 name
CD3 name
For tutorials and books see my answer to this question:
http://stackoverflow.com/questions/339930/any-good-xslt-tutorial-book-blog-site-online/341589#341589