XML parsing

Fredrik Lundh fredrik at pythonware.com
Mon Dec 13 04:27:17 EST 1999


Phil Hunt <philh at vision25.demon.co.uk> wrote:
> I am parsing some XML input using the xmllib module.
> 
> I am getting an error because my input file starts with
> <?xml version="1.1" ...
> but xmllib checks for this and raises an exception because it
> isn't version 1.0.
> 
> Is there any way to get xmllib to attempt to do something
> sensible when it gets input it doesn't like, rather than just
> raising an exception and refusding to read the file?

raising an exception is sensible, and in accordance
with the XML 1.0 specification:

    "Processors may signal an error if they receive
    documents labeled with versions they do not
    support."

> Or do I have to write my own XML parser?

if you can find the XML 1.1 specification (I cannot,
and I don't think there is one...), go ahead.

(but it's probably easier to tell your data provider
to stop using bogus version numbers...)

</F>





More information about the Python-list mailing list