0

假设我有一个 xml 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <quarkSettings>
    <UpdatePath></UpdatePath>
    <Version>Development</Version>
    <Project>ABC</Project>
  </quarkSettings>
</configuration>

现在我想获得项目的价值。我写了以下代码:

        import xml.etree.ElementTree as ET
        doc1 = ET.parse("Configuration.xml")
        for e in doc1.find("Project"):
                project =e.text

但它没有给出价值。

4

1 回答 1

1

我得到了答案:

import xml.etree.ElementTree as ET            
doc1 = ET.parse(get_path_for_config_Quark_Release)
root = doc1.getroot()
for element in root.findall("quarkSettings"):
    project = element.find("Project").text
于 2013-04-30T06:52:35.847 回答