SGMLParser error on HTML comment

Sean 'Shaleh' Perry shalehperry at home.com
Sun Nov 18 13:09:18 EST 2001


> 
> <!- URL to this page -->
> 
> <!- Name of the key parameter used for search/browse -->
> 
>   <!-  Send a Views Item event that we browsed this category -->
>   
> 

if this is an exact paste here lies your problem, the tag is <!-, note the
missing hyphen.

A workaround could be catching the SGMLParseError and looking at the token it
was trying to parse.  If the token matches a regex or some other means then you
could just ignore the exception and move on.

Your other choice would be to derive a new SGMLParser class and change the
definition of a comment to accept <!- -->, probably making the closing tags
second hyphen option as well.  If you look at sgmllib.py you will see that this
is very easy.




More information about the Python-list mailing list