May-27-2021, 02:01 AM
(May-25-2021, 04:12 PM)snippsat Wrote: I showed you how to parseW2Testfile.xml
in your last Thread, both with using BS and lxml for the task.
IRSW2.xsd
is used for Validation,you still miss a file for that to workefileTypes.xsd
(see that is referenced in IRSW2.xsd).
# Line 11 <xsd:include schemaLocation="efileTypes.xsd"/>from lxml import etree xml_file = etree.parse("W2Testfile.xml") xml_validator = etree.XMLSchema(file="IRSW2.xsd") Thanks. I am attaching .xsd, .xml that validates to TURE. from lxml import etree xml_file = etree.parse("Test41.xml") xml_validator = etree.XMLSchema(file="Test41.xsd") is_valid = xml_validator.validate(xml_file) print(is_valid) is_valid = xml_validator.validate(xml_file) print(is_valid)How to validate an XML file with an XML schema in Python
Error:.... lxml.etree.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}include': Failed to load the document 'efileTypes.xsd' for inclusion., line 11
testdata.zip contain Test41.xml. Test41.xsd, efilesTypes.xsd
testata.zip (Size: 16.37 KB / Downloads: 117)
How do I make xpath list for this .xml & .xsd?
Thanks for your help.