Ameteur XMLer here. Forgive misused terminology.
I am wondering if there is an xpath expression which allows me to select a single node from a group of sibling nodes.
XML:
As opposed to dumping all data in my <state> nodes into a table I would only like to produce the Data from the first <state> node -- Colorado. All I am currently familiar with is the <xsl:value-of> tag, which will in turn dump all data. I would like to display Colorado only. Clearly the value-of tag is an incorrect expression to produce such results. I'm just not sure what is.
Or to complicate things even more, is it possible to produce a result for the <state> node containing data Texas, skipping the two results prior to the data Texas.
Hope I am clear enough. Difficulty expressing myself over here =o
I am wondering if there is an xpath expression which allows me to select a single node from a group of sibling nodes.
XML:
Code:
<whereto>
<state>colorado</state>
<state>florida</state>
<state>texas</state>
<state>utah</state>
<state>newjersey</state>
<state>newyork/state>
<state>arizona</state>
<state>hawaii</state>
</whereto>
XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] version="1.0">
<xsl:template match="whereto">
<html>
<body>
<table border="1" cellpadding="3">
<th>
Places to go
</th>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="state">
<tr>
<td>
<xsl:value-of select="."/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
As opposed to dumping all data in my <state> nodes into a table I would only like to produce the Data from the first <state> node -- Colorado. All I am currently familiar with is the <xsl:value-of> tag, which will in turn dump all data. I would like to display Colorado only. Clearly the value-of tag is an incorrect expression to produce such results. I'm just not sure what is.
Or to complicate things even more, is it possible to produce a result for the <state> node containing data Texas, skipping the two results prior to the data Texas.
Hope I am clear enough. Difficulty expressing myself over here =o