root.tag显示意外结果

时间:2019-01-09 13:07:30

标签: xml python-3.x xml-parsing elementtree

我正在尝试使用ElementTree从pptx中提取文本。

xml如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
<Template>TM03457452[[fn=Celestial]]</Template>
.
.
.
.
</Properties>

python脚本:

import xml.etree.ElementTree as ET
import csv

tree = ET.parse("docProps/app.xml")
root = tree.getroot()

print(root.tag)

运行代码将打印“ {Spring JIRA ticket}属性,而不仅仅是“属性”。

将findall函数与root一起使用无法找到任何标签,并返回一个空数组。

0 个答案:

没有答案