elementtree and entities

Daniel Nogradi nogradi at gmail.com
Sun May 13 12:27:17 EDT 2007


Hi list,

How does one prevent elementtree converting & to & (and similarly
for other entities)?

>>> from xml.etree import ElementTree as et
>>> x = et.Element( 'test' )
>>> x.text = '&'
>>> et.tostring( x )
'<test>&</test>'

Sometimes I would like to have the output '<test>&</test>'

Daniel



More information about the Python-list mailing list