<p>我不知道为什么<code>findall('type')</code>而XML不包含任何<code><type></code>元素。根据发布的XML,它应该是<code>findall('Word')</code>。下面是一个最小但完整的演示代码:</p>
<pre><code>raw = '''<SpeechSegment spkid="S0">
<Word dur="0.22" stime="0.44">oh</Word>
<Word dur="0.27" stime="1.67">bedankt</Word>
<Word dur="0.3" stime="2.03">voor</Word>
<Word dur="0.53" stime="2.61">deelname</Word>
<Word dur="0.22" stime="3.15">aan</Word>
<Word dur="0.23" stime="3.39">de</Word>
<Word dur="0.14" stime="6.15">want</Word>
<Word dur="0.07" stime="6.29">ik</Word>
<Word dur="0.09" stime="6.36">wil</Word>
<Word dur="0.06" stime="6.45">je</Word>
<Word dur="0.42" stime="6.51">graag</Word>
<Word dur="0.2" stime="7.52">en</Word>
</SpeechSegment>'''
from xml.etree import ElementTree as ET
root = ET.fromstring(raw)
result = [word.text for word in root.findall('Word')]
print result
</code></pre>
<p><strong><kbd><a href="https://eval.in/805771" rel="nofollow noreferrer">^{<cd4>}</a></kbd></strong></p>
<p><strong>输出:</strong></p>
<pre><code>['oh', 'bedankt', 'voor', 'deelname', 'aan', 'de', 'want', 'ik', 'wil', 'je', 'graag', 'en']
</code></pre>