我需要能夠將平坦的xml數據集轉換爲html表格,並且無法找到適合我需要的語法示例。我想使用一個樣式表,可以將類似的外觀數據集轉換爲具有可變列的html表格。這意味着除了「行」和「行」之外,它不能使用任何硬編碼的元素名稱。使用XSLT將XML轉換爲HTML表
後,我的樣式表將能夠轉換:
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<AccountId>BlPUAA0</AccountId>
<AccountName>Initech</AccountName>
<AcocuntStatus>Client</AcocuntStatus>
</row>
<row>
<AccountId>CJxIAAW</AccountId>
<AccountName>Intertrode</AccountName>
<AcocuntStatus>Prospect</AcocuntStatus>
</row>
</rows>
到:
<table>
<tr>
<th>AccountId</th>
<th>AccountName</th>
<th>AcocuntStatus</th>
</tr>
<tr>
<td>BlPUAA0</td>
<td>Initech</td>
<td>Client</td>
</tr>
<tr>
<td>CJxIAAW</td>
<td>Intertrode</td>
<td>Client</td>
</tr>
</table>
這:
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<AccountId>BlPUAA0</AccountId>
<AccountName>Initech</AccountName>
</row>
<row>
<AccountId>CJxIAAW</AccountId>
<AccountName>Intertrode</AccountName>
</row>
</rows>
到這一點:
<table>
<tr>
<th>AccountId</th>
<th>AccountName</th>
</tr>
<tr>
<td>BlPUAA0</td>
<td>Initech</td>
</tr>
<tr>
<td>CJxIAAW</td>
<td>Intertrode</td>
</tr>
</table>
一定要向別人學習答案。這種模板「磚」不是很有用。 – 2011-04-16 05:37:39