insert html into ElementTree without parsing it

graeme.pietersz at gmail.com graeme.pietersz at gmail.com
Mon Feb 24 04:45:15 EST 2014


I am building HTML pages using ElementTree.

I need to insert chunks of untrusted HTML into the page. I do not need or want to parse this, just insert it at a particular point as is.

The best solutions I can think of are rather ugly ones: manipulating the string created by tostring.

Is there a nicer way of doing this? Is it possible, for example, to customise how an element is converted to a string representation? I am open to using something else (e.g. lxml) if necessary.



More information about the Python-list mailing list