Using an DTD not specified in XML file for validation
Enrico
4564 at 755189.45
Thu Aug 7 03:49:59 EDT 2008
"Brian Quinlan" <brian at sweetapp.com> ha scritto nel messaggio
news:mailman.1200.1218043709.922.python-list at python.org...
> Hey,
>
> I'm trying to figure out how I can validate an XML file using a DTD that
> isn't specified in the XML file.
I did it once using lxml. You can read from:
http://codespeak.net/lxml/validation.html
With this package is quite simple (code not tested):
from lxml import etree
dtd = etree.DTD('mydtd.dtd')
f = file('mydoc.xml')
xml = etree.XML(f.read())
dtd.validate(xml)
Enrico
More information about the Python-list
mailing list