Next / Previous / Contents / TCC Help System / NM Tech homepage

6.9. The tostring() function: Serialize as XML

To convert an Element and its content back to XML, use a function call of this form:

etree.tostring ( elt, pretty_print=False )

where elt is an Element instance. The function returns a string containing the XML. For an example, see Section 6.8, “The SubElement() constructor”.

If you set the optional pretty_print argument to True, the method will attempt to insert line breaks to keep line lengths short where possible.