This project has moved and is read-only. For the latest updates, please go here.


Implement _elementtree module


Not much documentation on this module. It's used by the 'xml' stdlib package.
Closed Dec 9, 2014 at 8:37 PM by jdhardy
Migrated to GitHub.


pekkaklarck wrote Nov 11, 2010 at 5:21 PM

IronPython 2.6.1 already has some code under xml.etree. Unfortunately even this fails:

IronPython 2.6.1 (2.6.10920.0) on .NET 4.0.30319.1
Type "help", "copyright", "credits" or "license" for more information.
from StringIO import StringIO
from xml.etree import ElementTree as ET
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\xml\etree\", line 862, in parse
File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\xml\etree\", line 581, in parse
File "C:\Program Files\IronPython 2.6 for .NET 4.0\Lib\xml\etree\", line 1117, in init
ImportError: No module named expat; use SimpleXMLTreeBuilder instead
It seems SimpleXMLTreeBuilder is not included in xml.etree so basically using the provided ElementTree implementation isn't possible. I just tested that elementtree 1.2.7 preview release [1], which should have better IronPython support than 1.2.6, works well in my project. Does something prevent including it into IronPython?


wrote Dec 16, 2010 at 8:57 AM

af001 wrote Dec 16, 2010 at 9:01 AM

The elementtree module is a core component for xml handling in python. It is essential for it to work!

Seo Sanghyeon appears to have written pyexpat/ElementTree for IronPython (a pyexpat emulation for IronPython which lets you use the standard ElementTree module on that platform). At least this should be included into the distribution.

The current ironpython distribution (2.6.1) has the unfortunate approach of providing a module for input that breaks immediately.

wrote Feb 7, 2011 at 9:14 AM

wrote Mar 13, 2011 at 5:07 AM

pekkaklarck wrote Oct 10, 2011 at 2:14 PM

I'm surprised this issue is considered low priority because not having a working ElementTree implementation in IronPython is a big blocker for many Python programs. I know this is an open source project with limited resources but in this case there already is a working implementation that ought to be easy to take into use (see my nearly a year old comment above about ET 1.2.7).

What's worse than not having ET is having an implementation that can be imported but not used. This means that even if you install a working ET, any code that uses the "standard" way to conditionally import ET (see e.g. still doesn't work because you end up getting a broken ET implementation anyway.

jdhardy wrote Oct 11, 2011 at 4:51 PM

This issue is low priority because it refers to the _elementtree C accelerator module. To make ET work, IronPython needs a pyexpat implmentation ([workitem:20023]) or, as you pointed last year (sorry!), an upgrade to ET.

pekkaklarck wrote Oct 11, 2011 at 8:28 PM

Submitted issue #31579 about changing ET implementation to IPY compatible version.

wrote Nov 3, 2011 at 5:56 AM

wrote Mar 10, 2012 at 8:32 AM

wrote Aug 23, 2012 at 12:36 AM

wrote Feb 22, 2013 at 2:13 AM

wrote Dec 9, 2014 at 8:37 PM