Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Most objects in Python are represented as dicts underneath:</p> <pre><code>&gt;&gt;&gt; class Fred(object) : ... def __init__(self, n) : self.n = n ... &gt;&gt;&gt; a = Fred(100) &gt;&gt;&gt; print a.__dict__ {'n': 100} </code></pre> <p>So this is similar to asking how to convert dicts to XML. There are tools for converting dict to/from XML at:</p> <p><a href="http://www.picklingtools.com" rel="nofollow">http://www.picklingtools.com</a></p> <p>Here is a simple example:</p> <pre><code> &gt;&gt;&gt; import xmltools &gt;&gt;&gt; d = {'a':1, 'b':2.2, 'c':'three' } &gt;&gt;&gt; xx = xmltools.WriteToXMLString(d) &gt;&gt;&gt; print xx &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;top&gt; &lt;a&gt;1&lt;/a&gt; &lt;b&gt;2.2&lt;/b&gt; &lt;c&gt;three&lt;/c&gt; &lt;/top&gt; </code></pre> <p>There is a lot of documentation at the web site showing examples:</p> <p><a href="http://www.picklingtools.com/html/xmldoc.html" rel="nofollow">XML Tools Manual</a></p> <p>It is difficult to convert "exactly" between dicts and XML: What is a list? What do you do with attributes? How do you handle numeric keys? A lot of these issues have been addressed and are discussed in the XML tools documentation (above).</p> <p>Does speed matter to you? Or does ease of use matter? There is a pure C++ module (all written in C++), a pure Python module (all written in Python), and a Python C Extension module (written in C++, but wrapped so Python can call it). The C++ and the Python C Extension module are orders of magnitude faster, but of course require compiling to get going. The Python module should just work, but is slower:</p>
    singulars
    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. 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