|
From: | Eldad Cohen |
Subject: | [Fab-user] Function with loop |
Date: | Tue, 4 Sep 2018 14:25:57 +0300 |
import xml.etree.ElementTree as ET
tree = ET.parse("test.xml")
a = tree.find('parent')
for b in a.findall('child'):
if b.text.strip() == 'Jay/Doctor':
break
else:
ET.SubElement(a,"child").text="Jay/Doctor"
tree.write("test.xml")
[Prev in Thread] | Current Thread | [Next in Thread] |