Reputation: 5127
I am trying generate HTML code based of an xml file input shown below,expected out is shown below,somewhere I am messing up the logic,I am getting a different output..can anyone point to what the issue is?
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>
EXPECTED OUTPUT:-
<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>
ACTUAL OUTPUT:-
<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 CODE:-
Upvotes: 2
Views: 120
Reputation: 310069
TR_TEMPLATE.append(' <td>{}</td>'.format(cols[0]))
TR_TEMPLATE = '\n'.join(TR_TEMPLATE) #<--converts TR_TEMPLATE to a string
In the second line, you convert TR_TEMPLATE
from a list to a string. On susequent iterations through the loop, you're trying to use .append
on a string. you probably want to move the second line out of the loop and join
at the end.
Note that you have that same mistake at a few points in your code...
Upvotes: 4