【发布时间】:2012-11-05 16:10:01
【问题描述】:
我正在尝试根据下面显示的 xml 文件输入生成 HTML 代码,预期结果如下所示,在某处我弄乱了逻辑,我得到了不同的输出..谁能指出问题所在?
Input :-cr_fixes.xml file
<Fixes>
CR FA CL Title
409452 WLAN 656885 Age out RSSI values from buffer
409452, 12345 To Record HAL and SLM FW Event Logging
</Fixes>
预期输出:-
<table cellspacing="1" cellpadding="1" border="1">
<tr>
<th bgcolor="#67B0F9" scope="col">CR</th>
<th bgcolor="#67B0F9" scope="col">FA</th>
<th bgcolor="#67B0F9" scope="col">CL</th>
<th bgcolor="#67B0F9" scope="col">Title</th>
</tr>
<tr>
<td><a href="http://prism/CR/409452">409452</a></td>
<td>WLAN</td>
<td>656885</td>
<td>Age out RSSI values from buffer </td>
</tr>
<tr>
<td><a href=http://data/409452>409452</a>,<a href=http://data/12345>12345</a></td>
<td></td>
<td></td>
<td>To Record HAL and SLM FW Event Logging</td>
</tr>
</table>
实际输出:-
<table cellspacing="1" cellpadding="1" border="1">
<tr>
<th bgcolor="#67B0F9" scope="col">CR</th>
<th bgcolor="#67B0F9" scope="col">FA</th>
<th bgcolor="#67B0F9" scope="col">CL</th>
<th bgcolor="#67B0F9" scope="col">Title</th>
</tr>
<tr>
<td><a href="http://prism/CR/409452">409452</a></td>
<td><a href="http://prism/CR/409452">409452</a></td>
<td><a href="http://prism/CR/409452">409452</a></td>
<td><a href="http://prism/CR/409452">409452</a></td>
<td>WLAN</td>
<td>656885</td>
<td>Age out RSSI values from buffer </td>
</tr>
<tr>
<td><a href="http://prism/CR/409452, 12345">409452, 12345</a></td>
<td><a href="http://prism/CR/409452, 12345">409452, 12345</a></td>
<td><a href="http://prism/CR/409452, 12345">409452, 12345</a></td>
<td><a href="http://prism/CR/409452, 12345">409452, 12345</a></td>
<td></td>
<td></td>
<td>To Record HAL and SLM FW Event Logging</td>
</tr>
</table>
Python 代码:-
【问题讨论】:
-
您的代码有一些缩进问题,您可能需要考虑修复——这不是
SyntaxError。这是AttributeError -
问题出在粘贴时..这里是pastie.org/5389908
-
我修复了属性错误并更新了代码,逻辑上我搞砸了,没有得到预期的输出
标签: python html python-2.7