diff --git a/Backend-libXML/Parser.py b/Backend-libXML/Parser.py index 14ce916..e019649 100644 --- a/Backend-libXML/Parser.py +++ b/Backend-libXML/Parser.py @@ -1,5 +1,5 @@ from lxml import etree - +from io import BytesIO def prettify(source: str) -> str: """Method used to pretty format given XML @@ -48,8 +48,8 @@ def xpath(source: str, xpath: str) -> str: :return: Nodes selected using XPath """ - - root = etree.XML(source) + byte_input = BytesIO(source.encode("utf-8")) + root = etree.parse(byte_input).getroot() nsmap = root.nsmap # LXML doesn't accept empty (None) namespace prefix, @@ -61,7 +61,7 @@ def xpath(source: str, xpath: str) -> str: # root.xpath can return 4 types: float, string, bool and list. # List is the only one that can't be simply converted to str - if result is not list: + if type(result) is not list: return str(result) else: result_string = ""