0
    <?xml version="1.0" encoding="UTF-8"?><rowset>
    <Row>
    <Column1>1381.00000</Column1>
    <Column2>9851.00000</Column2>
    <Column3>10.00000</Column3> 
    <Column4>130253.00000</Column4>
    <Column5>8065.88235</Column5>
    </Row> </rowset>

其他一些 xml 有不同数量的这样的列,

    <?xml version="1.0" encoding="UTF-8"?><rowset>
    <Row>
    <Column1>1551.00000</Column1>
    <Column2>977.00000</Column2>
    <Column3>9.00000</Column3>
    </Row></rowset>

这是我尝试过的东西,但它仅适用于具有 3 列的 xml 记录,我想让它动态化

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:template match="/">
      <html>
         <body>
            <h2>Metric Validator</h2>
            <table border="1">
               <tr bgcolor="#9acd32">
                  <th>Column1</th>
                  <th>Column2</th>
                  <th>Column3</th>
               </tr>
               <xsl:for-each select="rowset/Row">
                  <tr>
                     <td>
                        <xsl:value-of select="Column1" />
                     </td>
                     <td>
                        <xsl:value-of select="Column2" />
                     </td>
                     <td>
                        <xsl:value-of select="Column3" />
                     </td>
                  </tr>
               </xsl:for-each>
            </table>
         </body>
      </html>
   </xsl:template>
</xsl:stylesheet>
4

1 回答 1

1
...
<tr bgcolor="#9acd32">
  <xsl:for-each select="rowset/Row[1]/*">
   <th><xsl:value-of select="name()"/></th>
  </xsl:for-each>
</tr>
<xsl:for-each select="rowset/Row">
  <tr>
  <xsl:for-each select="*">
   <td><xsl:value-of select="."/></td>
  </xsl:for-each>
  </tr>
</xsl:for-each>
...
于 2013-08-20T12:52:59.560 回答