Re: Howto create this XML string?

Sbaush <[email protected]>
Newsgroups gmane.comp.python.xml
Message-ID <[email protected]>
I have

tree = ET.ElementTree(root)

How can i put tree in a string?

2006/1/20, Fredrik Lundh <[email protected]>:
>
> Sbaush wrote:
>
> > Is possible to have the XML in a string (for example xmlstring) and for
> > printing do a print xmlstring ?
>
> most about anything that can be written to a file can be written to a
> string
> using the StringIO module:
>
>     http://www.effbot.org/librarybook/stringio.htm
>
>     file = StringIO.StringIO()
>     tree.write(file)
>     data = file.getvalue()
>
> for elementtree, you can also use the tostring function:
>
>     data = ET.tostring(elem)
>
> </F>
>
>
>
> _______________________________________________
> XML-SIG maillist  -  [email protected]
> http://mail.python.org/mailman/listinfo/xml-sig
>



--
Sbaush

_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.