<p>在下面的简单示例中,<a href="https://docs.python.org/2/library/xml.etree.elementtree.html#xml.etree.ElementTree.parse" rel="noreferrer">^{<cd1>}</a>失败,并出现错误</p>
<blockquote>
<p>xml.etree.ElementTree.ParseError: XML or text declaration not at start of entity: line 2, column 0</p>
</blockquote>
<p>XML看起来是有效的,代码也很简单,那么我做错了什么?</p>
<pre><code>xmlExample = """
<?xml version="1.0"?>
<data>
stuff
</data>
"""
import io
source = io.StringIO(xmlExample)
import xml.etree.ElementTree as ET
tree = ET.parse(source)
</code></pre>