awacke1 commited on
Commit
f1cfab3
·
1 Parent(s): 81ab5e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -38,10 +38,19 @@ def get_table_download_link(file_path):
38
  href = f'<a href="data:file/htm;base64,{b64}" target="_blank" download="{os.path.basename(file_path)}">{os.path.basename(file_path)}</a>'
39
  return href
40
 
 
 
 
 
 
41
  def CompressXML(xml_text):
42
  root = ET.fromstring(xml_text)
43
- ET.strip_elements(root, ET.Comment)
44
- return ET.tostring(root, encoding='unicode')
 
 
 
 
45
 
46
  def read_file_content(file):
47
  if file.type == "application/json":
 
38
  href = f'<a href="data:file/htm;base64,{b64}" target="_blank" download="{os.path.basename(file_path)}">{os.path.basename(file_path)}</a>'
39
  return href
40
 
41
+ def add_parent_info(elem, parent=None):
42
+ for child in elem:
43
+ child.parent = parent
44
+ add_parent_info(child, parent=elem)
45
+
46
  def CompressXML(xml_text):
47
  root = ET.fromstring(xml_text)
48
+ add_parent_info(root)
49
+ for elem in list(root.iter()):
50
+ if isinstance(elem.tag, str) and 'Comment' in elem.tag:
51
+ elem.parent.remove(elem)
52
+ return ET.tostring(root, encoding='unicode', method="xml")
53
+
54
 
55
  def read_file_content(file):
56
  if file.type == "application/json":