From a90cbb938f99cfee9925e31cd4462b71546daa6a Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Thu, 2 Mar 2023 11:08:00 +0100 Subject: [PATCH] Partial fix for #75 - fixes problem in libXML (#92) Co-authored-by: Adam Bem Reviewed-on: https://gitea.release11.com/R11/release11-tools-web/pulls/92 --- Backend-libXML/Parser.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Backend-libXML/Parser.py b/Backend-libXML/Parser.py index 67ebfc1..14ce916 100644 --- a/Backend-libXML/Parser.py +++ b/Backend-libXML/Parser.py @@ -58,10 +58,16 @@ def xpath(source: str, xpath: str) -> str: nsmap.pop(None) result = root.xpath(xpath, namespaces=nsmap) - result_string = "" - for e in result: - result_string += etree.tostring(e, pretty_print=True).decode() + "\n" - return result_string + + # 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: + return str(result) + else: + result_string = "" + for e in result: + result_string += etree.tostring(e, pretty_print=True).decode() + "\n" + return result_string