Co-authored-by: Adam Bem <adam.bem@zoho.eu> Reviewed-on: R11/release11-tools-web#92
This commit is contained in:
@@ -58,10 +58,16 @@ def xpath(source: str, xpath: str) -> str:
|
|||||||
nsmap.pop(None)
|
nsmap.pop(None)
|
||||||
|
|
||||||
result = root.xpath(xpath, namespaces=nsmap)
|
result = root.xpath(xpath, namespaces=nsmap)
|
||||||
result_string = ""
|
|
||||||
for e in result:
|
# root.xpath can return 4 types: float, string, bool and list.
|
||||||
result_string += etree.tostring(e, pretty_print=True).decode() + "\n"
|
# List is the only one that can't be simply converted to str
|
||||||
return result_string
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user