bappa147
bappa147

Reputation: 539

How to get node's value of an XML in Python?

suppose i have an xml file:

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

now i want get Project's value. I have written following code:

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

but it doesn't give the value.

Upvotes: 0

Views: 6784

Answers (1)

bappa147
bappa147

Reputation: 539

i got the answer:

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

Upvotes: 2

Related Questions