fix libxml xpath bugs
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user