Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>Elements</code> (like <code>root</code>) do not have a <code>write</code> method, but <a href="http://lxml.de/tutorial.html#the-elementtree-class" rel="noreferrer">ElementTrees</a> do:</p> <pre><code>from lxml import etree root = etree.Element('root1') element = etree.SubElement(root, 'element1') tree = root.getroottree() print(type(tree)) # &lt;type 'lxml.etree._ElementTree'&gt; tree.write('xmltree.xml') </code></pre> <hr> <p>The documentation on <code>tree.write</code> is a little hard to find on the web. Here is the method's doc string:</p> <pre><code>In [7]: tree.write? Type: builtin_function_or_method Base Class: &lt;type 'builtin_function_or_method'&gt; String Form: &lt;built-in method write of lxml.etree._ElementTree object at 0x95c48cc&gt; Namespace: Interactive Docstring: write(self, file, encoding=None, method="xml", pretty_print=False, xml_declaration=None, with_tail=True, standalone=None, compression=0, exclusive=False, with_comments=True) Write the tree to a filename, file or file-like object. Defaults to ASCII encoding and writing a declaration as needed. The keyword argument 'method' selects the output method: 'xml', 'html', 'text' or 'c14n'. Default is 'xml'. The ``exclusive`` and ``with_comments`` arguments are only used with C14N output, where they request exclusive and uncommented C14N serialisation respectively. Passing a boolean value to the ``standalone`` option will output an XML declaration with the corresponding ``standalone`` flag. The ``compression`` option enables GZip compression level 1-9. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload