[newbie] Easier way to check if element exists, edit if exists, insert if not?

Sept. 16, 2021
10:55 p.m.
Hello, Out of curiosity, is there a more compact way to check if an element exists, edit if it does, insert if it doesn't ? #=========== Edit/insert top-most name r = root.find('./Document/name') #if et.iselement(r) if r is not None: print("Name exists: ",r.text) r.text = BASENAME else: print("Name does not exist") #insert new element et.SubElement('/kml/Document', "name").text = BASENAME Thank you.
1256
Age (days ago)
1256
Last active (days ago)
0 comments
1 participants
participants (1)
-
Gilles