I have some XML file i want to validate and i have to do it with Python. I've tryed to validate it with XSD with lxml. But i get only one error which occurs first but i need all errors and mismatches in XML file. Is there any method how i can manage to get list of all errors with lxml? Or are there any other Python solutions?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- Illegal to have multiple roots (start tag in epilo
- How to get the background from multiple images by
- Evil ctypes hack in python
The solution provided doesn't work anymore due to several errors. Before applying assertValid on xmlschema, you have to specify it as follows:
You can read the Python docs on Error exceptions to find out how to do a
try/except
design pattern, and in theexcept
part you can store the mismatches (a list, or a list of pairs, for example), then recursivelytry/except
again beginning at the point after the first error. Let me know if that isn't descriptive enough.Cheers!
The way to solve this problem was:
May be there are better ways to solve this problem :)
With
lxml
, you can iterate overerror_log
and print line number and error message for each error: