[IronPython] ElementTree bug?

David Escobar davidescobar1976 at gmail.com
Fri Jun 18 20:51:22 CEST 2010


Hi everyone,
There seems to be an inconsistency in the ElementTree class between CPython
and IronPython.

In CPython 2.6.4:

*Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml.etree.ElementTree as etree
>>> xml_str = "<Message><User>David</User><Phone>123-4567</Phone></Message>"
>>> xml = etree.XML(xml_str)
>>> print xml.find("Phone").text
123-4567
>>>
*

In IronPython 2.6.1:

*IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.3603
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml.etree.ElementTree as etree
>>> xml_str = "<Message><User>David</User><Phone>123-4567</Phone></Message>"
>>> xml = etree.XML(xml_str)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\IronPython 2.6\Lib\xml\etree\ElementTree.py", line
962,
 in XML
  File "C:\Program Files\IronPython 2.6\Lib\xml\etree\ElementTree.py", line
1117
, in __init__
ImportError: No module named expat; use SimpleXMLTreeBuilder instead
>>> xml = etree.fromstring(xml_str)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\IronPython 2.6\Lib\xml\etree\ElementTree.py", line
962,
 in XML
  File "C:\Program Files\IronPython 2.6\Lib\xml\etree\ElementTree.py", line
1117
, in __init__
ImportError: No module named expat; use SimpleXMLTreeBuilder instead
>>>
*

So both XML and fromstring fail to parse the xml string. Is this a bug?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100618/7d2b2107/attachment.html>


More information about the Ironpython-users mailing list