Hi everyone,<br>There seems to be an inconsistency in the ElementTree class between CPython and IronPython.<br><br>In CPython 2.6.4:<br><br><b><span style="font-family: courier new,monospace;">Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">win32</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Type "help", "copyright", "credits" or "license" for more information.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">>>> import xml.etree.ElementTree as etree</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">>>> xml_str = "<Message><User>David</User><Phone>123-4567</Phone></Message>"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">>>> xml = etree.XML(xml_str)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">>>> print xml.find("Phone").text</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">123-4567</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">>>></span><br style="font-family: courier new,monospace;">
</b><br><br>In IronPython 2.6.1:<br><br><b><span style="font-family: courier new,monospace;">IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.3603</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Type "help", "copyright", "credits" or "license" for more information.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">>>> import xml.etree.ElementTree as etree</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">>>> xml_str = "<Message><User>David</User><Phone>123-4567</Phone></Message>"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">>>> xml = etree.XML(xml_str)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Traceback (most recent call last):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> File "<stdin>", line 1, in <module></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> File "C:\Program Files\IronPython 2.6\Lib\xml\etree\ElementTree.py", line 962,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> in XML</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> File "C:\Program Files\IronPython 2.6\Lib\xml\etree\ElementTree.py", line 1117</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">, in __init__</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ImportError: No module named expat; use SimpleXMLTreeBuilder instead</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">>>> xml = etree.fromstring(xml_str)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Traceback (most recent call last):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> File "<stdin>", line 1, in <module></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> File "C:\Program Files\IronPython 2.6\Lib\xml\etree\ElementTree.py", line 962,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> in XML</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> File "C:\Program Files\IronPython 2.6\Lib\xml\etree\ElementTree.py", line 1117</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">, in __init__</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ImportError: No module named expat; use SimpleXMLTreeBuilder instead</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">>>></span><br></b><br><br>So both XML and fromstring fail to parse the xml string. Is this a bug?<br><br>