I have a very simple file from which I would like to extract the number values, only when the type is flower.
<myRoot>
<header>
...
</header>
<body>
...
<div type="animal" number="431">text1</div>
<div type="flower" number="812">text2</div>
<div type="flower" number="619">text3</div>
...
</body>
</myRoot>
The exit I'm waiting for is :
812
619
My current xslt file is :
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" indent="no" />
<xsl:template match="//div">
<xsl:value-of select="@type='flower'"/>
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
xsl:output method="html", I would expect to see some HTML in the result you want, yet you have only shown plain text. As for selecting your attributes, use//div[@type = 'flower']/@numberas the path, with an XSLT 2 or 3 processor you can simply use that path in<xsl:value-of select="//div[@type = 'flower']/@number"/>, with an XSLT 1 processor you will need to push the selected attributes through a template or pull them in throughxsl:for-each.