使用ElementTree进行XML解析会产生错误的输出

2024-10-01 22:34:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用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,还是它有问题?你知道吗


Tags: 文件函数text标记importabstract错误some

热门问题