From b9786df52e86c8b0ca60600a19d93e977477de30 Mon Sep 17 00:00:00 2001 From: kthoden Date: Fri, 9 Jul 2021 11:07:52 +0200 Subject: [PATCH] Add function to check for empty element --- src/utils/libeoaconvert.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/utils/libeoaconvert.py b/src/utils/libeoaconvert.py index b508d4c..06ec58d 100644 --- a/src/utils/libeoaconvert.py +++ b/src/utils/libeoaconvert.py @@ -369,6 +369,21 @@ def transfer_xml_attributes(old_element_attributes, new_element): return # def transfer_xml_attributes ends here + +def check_xml_empty(xml_element): + """Check if an element has neither attributes, text or children""" + + attributes = xml_element.attrib + text = xml_element.text + children = xml_element.getchildren() + + if len(attributes) == 0 and text is None and len(children) == 0: + return True + else: + return False +# def check_xml_empty ends here + + def split_with_milestone_element(element, milestone, splitter): """Split the text of an element by inserting milestone tags."""