fix libxml xpath bugs

This commit is contained in:
2025-02-06 18:30:30 +01:00
parent ec1b56677d
commit 3b96031a42

View File

@@ -1,3 +1,5 @@
from typing import Any
from lxml import etree, html
from io import BytesIO
@@ -79,9 +81,11 @@ def xpath(source: str, xpath: str) -> str:
else:
result_string = ""
for e in result:
result_string += etree.tostring(e, pretty_print=True).decode() + "\n"
return result_string, "node"
if isinstance(e, etree._Element):
result_string += etree.tostring(e, pretty_print=True).decode() + "\n"
else:
result_string += str(e) + "\n"
return result_string, "node"
def xsd(source: str, xsd: str) -> bool: