SGMLParser error on HTML comment

Sean 'Shaleh' Perry shalehperry at home.com
Sat Nov 17 17:42:47 EST 2001


On 17-Nov-2001 George Thomas wrote:
> Hi everyone,
> There's the following post dated May 28, 2001 from Marcel van den Dungen. 
> Didn't see any replies. Has there been a fix ? Does anyone have any ideas 
> ?
>  >>>
> Hi,
> 
> I'm trying to parse a bunch of HTML files using the SGMLParser class,
> which works just fine unless an HTML-file starts with an HTML-comment
> marker before the <HTML> opening-tag.
> The following error is emited:
>   File "c:\python21\lib\sgmllib.py", line 238, in parse_declaration
>     raise SGMLParseError(
> sgmllib.SGMLParseError: unexpected char in declaration: '<'
> 
> Anybody know a fix or workaround for this?
> 

a quick look at sgmllib.py shows that you are falling into the case for
'<!DOCTYPE' and the parser is getting confused.

Could you post the first few lines of the html doc?




More information about the Python-list mailing list