awacke1 commited on
Commit
6bb2035
·
1 Parent(s): 5661371

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -4,7 +4,7 @@ import os
4
  import base64
5
  import glob
6
  import json
7
- from bs4 import BeautifulSoup
8
  from datetime import datetime
9
  from dotenv import load_dotenv
10
  from openai import ChatCompletion
@@ -46,8 +46,9 @@ def read_file_content(file):
46
  content = BeautifulSoup(file, "html.parser")
47
  return content.text
48
  elif file.type == "application/xml" or file.type == "text/xml":
49
- content = BeautifulSoup(file, "xml")
50
- return content.text
 
51
  elif file.type == "text/plain":
52
  return file.getvalue().decode()
53
  else:
 
4
  import base64
5
  import glob
6
  import json
7
+ from xml.etree import ElementTree
8
  from datetime import datetime
9
  from dotenv import load_dotenv
10
  from openai import ChatCompletion
 
46
  content = BeautifulSoup(file, "html.parser")
47
  return content.text
48
  elif file.type == "application/xml" or file.type == "text/xml":
49
+ tree = ElementTree.parse(file)
50
+ root = tree.getroot()
51
+ return ElementTree.tostring(root, encoding='unicode')
52
  elif file.type == "text/plain":
53
  return file.getvalue().decode()
54
  else: