<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">I have 



<meta name="Generator" content="Kate, the KDE Advanced Text Editor">

<pre>tree <span style="color: rgb(255, 0, 255);">=</span> ET.ElementTree<span style="color: rgb(255, 0, 255);">(</span>root<span style="color: rgb(255, 0, 255);">)</span></pre>How can i put tree in a string?<br><br><div>
<span class="gmail_quote">2006/1/20, Fredrik Lundh &lt;<a href="mailto:fredrik@pythonware.com">fredrik@pythonware.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Sbaush wrote:<br><br>&gt; Is possible to have the XML in a string (for example xmlstring) and for<br>&gt; printing do a print xmlstring ?<br><br>most about anything that can be written to a file can be written to a string
<br>using the StringIO module:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.effbot.org/librarybook/stringio.htm">http://www.effbot.org/librarybook/stringio.htm</a><br><br>&nbsp;&nbsp;&nbsp;&nbsp;file = StringIO.StringIO()<br>&nbsp;&nbsp;&nbsp;&nbsp;tree.write(file)<br>&nbsp;&nbsp;&nbsp;&nbsp;data = 
file.getvalue()<br><br>for elementtree, you can also use the tostring function:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;data = ET.tostring(elem)<br><br>&lt;/F&gt;<br><br><br><br>_______________________________________________<br>XML-SIG maillist&nbsp;&nbsp;-&nbsp;&nbsp;
<a href="mailto:XML-SIG@python.org">XML-SIG@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/xml-sig">http://mail.python.org/mailman/listinfo/xml-sig</a><br></blockquote></div><br><br clear="all"><br>-- 
<br>Sbaush