"Empty" text

Jan Danielsson jan.m.danielsson at gmail.com
Tue Jul 10 13:30:36 CEST 2007

André wrote:
>>    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?
> 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.

   The problem was actually as indicated by others, that the document
was not being served as application/xml+xhtml. The _real_ problem was
the fact that I know too little about http/html. I put a meta tag in the
head, indicating that it had the content type "application/xml+xhtml",
and thought that would do it. Which is obviously didn't.

   Once I added req.content_type = "application/xml+xhtml" to my
mod_python application, it worked properly. In the future, I'll be sure
to use the "View Page Info" feature in Firefox to actually check what
type my documents are being served as.

   I was surprised to find that some pages render quite differently,
just by changing content type from text/html to application/xml+xhtml.
(Quite a positive surprise, to me)

   A big "Thank you!" goes to those who helped me find the source of the

Kind regards,
Jan Danielsson

More information about the Python-list mailing list