Popular Python recipes tagged "meta:requires=celementtree"http://code.activestate.com/recipes/langs/python/tags/meta:requires=celementtree/2012-01-17T18:10:29-08:00ActiveState Code RecipesXML as Dictionary (Python)
2012-01-17T18:10:29-08:00Vikram Baghelhttp://code.activestate.com/recipes/users/4180561/http://code.activestate.com/recipes/578017-xml-as-dictionary/
<p style="color: grey">
Python
recipe 578017
by <a href="/recipes/users/4180561/">Vikram Baghel</a>
(<a href="/recipes/tags/xml/">xml</a>).
</p>
<p>I use this for configuration. I hadn't intended to put it up anywhere, but there have been a couple discussions lately about converting XML to python dicts, so I feel obligated to share another approach, one that is based on Fredrik Lundh's ElementTree.</p>
XML as Dictionary (Python)
2005-05-08T17:58:54-07:00Duncan McGreggorhttp://code.activestate.com/recipes/users/1923213/http://code.activestate.com/recipes/410469-xml-as-dictionary/
<p style="color: grey">
Python
recipe 410469
by <a href="/recipes/users/1923213/">Duncan McGreggor</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 5.
</p>
<p>I use this for configuration. I hadn't intended to put it up anywhere, but there have been a couple discussions lately about converting XML to python dicts, so I feel obligated to share another approach, one that is based on Fredrik Lundh's ElementTree.</p>
Converts a DOM node object of type element to an ElementTree Element (Python)
2006-10-25T12:09:30-07:00Richard Philipshttp://code.activestate.com/recipes/users/98125/http://code.activestate.com/recipes/498221-converts-a-dom-node-object-of-type-element-to-an-e/
<p style="color: grey">
Python
recipe 498221
by <a href="/recipes/users/98125/">Richard Philips</a>
(<a href="/recipes/tags/xml/">xml</a>).
</p>
<p>DOM2ET is a simple python function which converts a DOM node object of type element to an ElementTree Element.
<br>
Writing it, was a good exercise to understand the workings of ElementTree</p>
import ElementTree from everywhere (Python)
2006-07-14T01:19:09-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/475126-import-elementtree-from-everywhere/
<p style="color: grey">
Python
recipe 475126
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 4.
</p>
<p>effbot's ElementTree module (<a href="http://effbot.org/zone/element-index.htm" rel="nofollow">http://effbot.org/zone/element-index.htm</a>) is an excellent way to work with XML. It has a lot of incarnations though so distributing code that uses it right now is little bit of a pain. Here is a snippet you might want to use to import one of all the available incarnations -- hopefully the users of your script will have one.</p>