我希望我的代码出现在表格中。标题名称,地址和顺序为一行。然后数据出现在下面的单独行中,因此每个客户都有自己的行。目前他们都出现在彼此之下。
<xsl:template match="/Customers">
<html>
<body>
<h1>Customer Orders</h1>
<table>
<tr>
<th>Name</th>
<xsl:for-each select="Customer/CustomerName" >
<tr>
<td>
<xsl:value-of select="."/>
</td>
</tr>
</xsl:for-each>
</tr>
<tr>
<th>Address</th>
<xsl:for-each select="Customer/CustomerAddress" >
<tr>
<td>
<xsl:value-of select="."/>
</td>
</tr>
</xsl:for-each>
</tr>
<tr>
<th>Order</th>
<xsl:for-each select="Customer/OrderDesc" >
<tr>
<td>
<xsl:value-of select="."/>
</td>
</tr>
</xsl:for-each>
</tr>
</table>
</body>
</html>
答案 0 :(得分:2)
你可能想做:
<xsl:template match="/Customers">
<html>
<body>
<h1>Customer Orders</h1>
<table>
<tr>
<th>Name</th>
<th>Address</th>
<th>Order</th>
</tr>
<xsl:for-each select="Customer" >
<tr>
<td>
<xsl:value-of select="CustomerName"/>
</td>
<td>
<xsl:value-of select="CustomerAddress"/>
</td>
<td>
<xsl:value-of select="OrderDesc"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
未经测试,因为未提供任何代码。