I have the following XML:
<?xml version="1.0" encoding="utf-8" ?>
<data>
<record>
<id>1</id>
<name>David</name>
<age>40</age>
</record>
<record>
<id>2</id>
<name>Tully</name>
<age>38</age>
</record>
<record>
<id>3</id>
<name>Solai</name>
<age>32</age>
</record>
<record>
<id>4</id>
<name>Michael</name>
<age>49</age>
</record>
<record>
<id>5</id>
<name>Tony</name>
<age>19</age>
</record>
<record>
<id>6</id>
<name>Ray</name>
<age>26</age>
</record>
<record>
<id>7</id>
<name>Leeha</name>
<age>13</age>
</record>
</data>
I want to display the records as similar to a dataview in asp.net, like the following:
record 1 record2 record3 record4 record 5 record6 record7 record8
and so on.
I have the following XSL at the moment which is shakey to say the least!
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<div>
<table style="width: 200px" border="1">
<tr>
<xsl:for-each select="data/record">
<xsl:if test="position() mod 4 = 0">
<tr></tr>
</xsl:if>
<td>
<xsl:value-of select="name"></xsl:value-of>
<br />
<xsl:value-of select="age"></xsl:value-of>
</td>
</xsl:for-each>
</tr>
</table>
</div>
</xsl:template>
</xsl:stylesheet>
So my question is, am I on the correct path here.. or is there a more simple, robust way to achieve this?
Many thanks in advance.