XML Validation with Python

Will Stuyvesant hwlgw at hotmail.com
Wed Jul 2 13:01:58 EDT 2003


Can you give a commandline example how to do XML Validation (checking
against a DTD) with Python?  Not with 4Suite or other 3rd party
libraries, just the Python standard distribution.  I have Python 2.2
but can upgrade to 2.3 beta if needed.

I am looking for something like:

"
$ python validate.py myxmlfile.xml mydtd.dtd
"

where validate.py contains something like:

"
import somexmllib
import sys

# prints 1 if Okay :-)
print somexmllib.validate(sys.argv[1], sys.argv[2])
"

I am sorry if this is a FAQ or if it is in one of the xml libraries, I
just could not figure it out!




More information about the Python-list mailing list