How to check if XML has same values in different nodes using XSLT?
I am very new to XSLT and want your help
I have an XML with below format :
<?xml version="1.0" encoding="UTF-8"?> <Rowset> <Row> <ActualHour>0.64</ActualHour> </Row> <Row> <ActualHour>0.64</ActualHour> </Row> <Row> <ActualHour>0.64</ActualHour> </Row> </Rowset>
I want to know how can I check whether "ActualHour" has same values across different "Row" node using XSLT?
Thanks in advance.
Try:
<xsl:template match="/Rowset"> <output> <xsl:value-of select="not(Row/ActualHour!=Row/ActualHour)"/> </output> </xsl:template>
The result in your example will be:
<?xml version="1.0" encoding="UTF-8"?> <output>true</output>
With an input like:
<Rowset> <Row> <ActualHour>0.64</ActualHour> </Row> <Row> <ActualHour>0.65</ActualHour> </Row> <Row> <ActualHour>0.64</ActualHour> </Row> </Rowset>
the result will be false
.