I am trying to save values from an XML doc into a variable. I am aware you can do the following:
<xsl:variable name="variableName" select="xml/node/*"/>
Below is my XML code:
<xml>
<graph2>
<averageHighTemperatures>
<January>8.3</January>
<February>8.5</February>
<March>11.1</March>
<April>13.5</April>
<May>17.1</May>
<June>20.0</June>
<July>22.6</July>
<August>22.5</August>
<September>19.3</September>
<October>15.3</October>
<November>11.2</November>
<December>9.1</December>
</averageHighTemperatures>
</graph2>
</xml>
How can I select the value of each month by specifying the node in the XML doc?
Below is my XSL:
<xsl:variable name="var" select="xml/graph2/averageHighTemperatures/*"/>
<table>
<xsl:for-each select="xml/graph2/averageHighTemperatures">
<tr>
<td><xsl:value-of select="January $var"/></td>
<td><xsl:value-of select="February $var"/></td>
</tr>
</xsl:for-each>
</table>
In the above, "January" and "February" are only being used to present the value wanted.
$var? In the example, you are just trying to indicate that you would only want January and February's temps:<td>8.3</td><td>8.5<td>? If so, it would be helpful to add an example of the desired output. Your example XSLT is a little confusing, since it isn't clear whether you want "January" and "February" to appear in the output, or if you are just indicating that is the month's value that you want to be able to select.