XML parsing

Phil Hunt philh at vision25.demon.co.uk
Mon Dec 13 19:50:45 EST 1999


In article <m3iu22amb1.fsf at havenrock.com>
           mgushee at havenrock.com "Matt Gushee" writes:
> philh at vision25.demon.co.uk (Phil Hunt) writes:
> > 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?
> 
> Uh, first of all, could I ask why your input file starts with <?xml
> version="1.1"?>

Because it is what I am getting from the URL
   http://www.theregister.co.uk/tonys/slashdot.html

In spite of its name this is a RSS file (version 0.91).

> -- since there isn't any such thing yet ... AFAIK
> there isn't even a working draft for XML 1.1. *Please* don't tell me
> somebody's going off and trying to create their own 'improved' version
> of XML -- that's exactly how HTML got ruined.

It wouldn't surprise me.

> If it were me, I'd want to have a conversation with the producer(s) of 
> the documents about what is and is not XML. Or if their authoring
> tools are at fault, find whoever programmed those tools and give them
> an earfull.
> 
> But if you must accommodate this garbage, you might try writing your
> own XMLParser class:
> 
> import xmllib
> 
> class XMLParser(xmllib.XMLParser):
> 
>     ## and define only the following method -- which you can cut and
>     ## paste from xmllib.py, editing only the line that says
>     ##     if version[1:-1] != '1.0':
> 
>     def goahead(self, end):

Yeah, that did occur to me -- I was hoping to do it a bit more elegantly.
Oh well, if it works...

> Hope this helps a bit. Oh, and if you happen to be part of a
> super-secret group within the W3C that is, unbeknownst to the unwashed 
> masses, actually working on XML 1.1, I apologize for the above rant.

Our dastardly plot has been uncovered at last! :-)


-- 
Phil Hunt - - - phil at comuno.com
"Software is like sex, it's better when it's free" -- Linus Torvalds




More information about the Python-list mailing list