Howto create this XML string?

Fredrik Lundh fredrik at
Fri Jan 20 11:11:40 EST 2006

"Sbaush" wrote:

> in the elementtree implementation the tostring function doesn't work with a
> tree, work only with an element. What is the way to put the tree in a
> string?

this is the code you posted:

    root = ET.Element("manager")
    ... snip ...

    tree = ET.ElementTree(root)

if you need the root variable instead of the tree variable, use root instead of tree.

or read the ET documentation; it explains how to get the root from a tree:


More information about the Python-list mailing list