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 lxml import etree, html
from io import BytesIO from io import BytesIO
@@ -79,11 +81,13 @@ def xpath(source: str, xpath: str) -> str:
else: else:
result_string = "" result_string = ""
for e in result: for e in result:
if isinstance(e, etree._Element):
result_string += etree.tostring(e, pretty_print=True).decode() + "\n" result_string += etree.tostring(e, pretty_print=True).decode() + "\n"
else:
result_string += str(e) + "\n"
return result_string, "node" return result_string, "node"
def xsd(source: str, xsd: str) -> bool: def xsd(source: str, xsd: str) -> bool:
""" """
Method used to validate XML string against XSD schema Method used to validate XML string against XSD schema