confused with xml and minidom
Guy Robinson
guy at NOSPAM.r-e-d.co.nz
Wed Mar 24 20:21:40 EST 2004
Hello,
I've got an xhtml file which contains a number of html tables.
I want to parse these tables and based on values in the TD cells of the
body of the table delete the row and replace it with additional rows.
Then write the xhtml file to a new file.
so input.xhtml
<table>
<tbody>
<tr>
<td>param</td>
<td>param2</td>
<td>param3</td>
</tr>
</tbody>
</table>
becomes output.xhtml
<table>
<tbody>
<tr>
<td>r1v1</td>
<td>r1v2</td>
<td>r1v3</td>
</tr>
<tr>
<td>r2v1</td>
<td>r2v2</td>
<td>r2v3</td>
</tr>
<tr>
<td>r3v1</td>
<td>r3v2</td>
<td>r3v3</td>
</tr>
... etc
</tbody>
</table>
if I get the table by:
xmldoc = minidom.parse('templates/input.xhtml')
table = xmldoc.getElementsByTagName('table')
how do I then get the first row of with the parameters. Delete this row
and insert the new rows?
table.childnode('tbody').getElementsByTagname('tr') doesn't work.
Any help or examples of what I'm trying to do appreciated.
Thanks,
Guy
More information about the Python-list
mailing list