2015-12-04 128 views
0

我希望我的代碼出現在表中。標題名稱,地址和順序是一行。然後數據將出現在下面的單獨行中,因此每個客戶都有自己的行。目前它們全都出現在彼此之下。XML - 獲取數據進入表(格式)?

<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> 

未經檢驗的,因爲沒有提供任何代碼。