0
我有這個xml,當我通過一個xsl文件時,其餘部分顯示爲正常。但是,屬性只顯示第一個。我如何着手列出循環中的每個屬性?另外,這是設計我的xsl文件的好方法嗎?XML屬性在每個xsl中都不會更改
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rental.xsl"?>
<rentalProperties>
<property available="yes" contact="0499584010">
<type>house</type>
<address>
<streetNo>111</streetNo>
<street>say, Burwood Road</street>
<suburb>say, Hawthorn</suburb>
<state>VIC</state>
<zipcode>3122</zipcode>
</address>
</property>
<property available="no" contact="0485776610">
<type>apartment</type>
<address>
<streetNo>111</streetNo>
<street>say, Burwood Road</street>
<suburb>say, Hawthorn</suburb>
<state>VIC</state>
<zipcode>3122</zipcode>
</address>
</property>
</rentalProperties>
我的XSL
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table border="1">
<tr>
<th>Availability</th>
<th>Contact</th>
<th>Type</th>
<th>Street Number</th>
<th>Street</th>
<th>Suburb</th>
<th>State</th>
<th>Zipcode</th>
</tr>
<xsl:for-each select="/rentalProperties/property">
<tr>
<td>
<xsl:value-of select="/rentalProperties/property/@available" />
</td>
<td>
<xsl:value-of select="/rentalProperties/property/@contact" />
</td>
<td>
<xsl:value-of select="type" />
</td>
<td>
<xsl:value-of select="address/streetNo" />
</td>
<td>
<xsl:value-of select="address/street" />
</td>
<td>
<xsl:value-of select="address/suburb" />
</td>
<td>
<xsl:value-of select="address/state" />
</td>
<td>
<xsl:value-of select="address/zipcode" />
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
謝謝!有效! – JianYA