On Jul 8, 5:23 pm, Jan Danielsson <[EMAIL PROTECTED]> wrote: > Hello all, > > I'm using mod_python+ElementTree to build XHTML pages. But I stumbled > across this problem: > > -------------------- > def foo(req, desc = None): > > ... > > tr = ET.SubElement(tbl, "tr") > th = ET.SubElement(tr, "th") > th.text = "Description" > td = ET.SubElement(tr, "td") > ta = ET.SubElement(td, "textarea", name="desc", rows="8", > cols="64") > if desc is None: > desc = '' > ta.text = desc > -------------------- > > The problem is that this generates the following code: > > <tr> > <th>Description</th> > <td> > <textarea cols="64" name="desc" rows="8" /> > </td> > </tr> > > Firefox is very unhappy about the textarea not having separate > opening and a closing tags. i.e. I need this: > > <textarea cols="64" name="desc" rows="8"></textarea> > > I understand the opitmization ElementTree is performing; but it seems > there are cases when it is not the proper thing to do. Is it possible to > force ElementTree to output the XHTML code I need it to? > > -- > Kind regards, > Jan Danielsson
I ran into the same problem and a workaround I found was to use either ta.text = " " or ta.text = "\n" instead of ta.text = ''. For my application, it did the right thing; your mileage may vary. André
-- http://mail.python.org/mailman/listinfo/python-list