0

ElementTree を使用して XML ファイルを解析したいのですが、特定のタグで出力が間違っています

<descriptions>
<description descriptionType="Abstract">Some Abstract Text
</description>
</descriptions>

だから私はXML関数でそれを解析します

import xml.etree.ElementTree as ElementTree
root = ElementTree.XML(my_xml)
root.getchildren()[0].items()

結果は次のとおりです。

Out: [('descriptionType', 'Abstract')]

XML に何か問題がありますか。ElementTree を間違った方法で使用していますか、それともバグですか?

4

2 に答える 2

0

タグがない場合は、テキスト属性に保存されていました..

于 2013-02-26T13:38:06.830 に答える
0

テキストを取得したいと思います。そう:

root.getchildren()[0].text

いいえ

root.getchildren()[0].items()
于 2013-02-26T13:38:18.773 に答える