XML Validation with Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Will Stuyvesant

    XML Validation with Python

    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.vali date(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!
Working...