HTMLParser problem

Richard Brodie R.Brodie at rl.ac.uk
Tue Nov 16 08:45:15 EST 2004


"Valkyrie" <valkyrie at cuhk.edu.hk> wrote in message news:1100610863.75889 at eng-ser4...

> <![if !IE]>
>
> HTMLParser.HTMLParseError: unknown declaration: 'if !IE', at line 4, column 1
>
> May I ask why such error is raised?

HTMLParser isn't very forgiving of bad HTML; you feed it syntactically invalid HTML,
it tends to give you errors. That includes Microsoft only extensions like <![if !IE.
Unless you know you have known valid sources it may be best to use one of
the forgiving parsers: Beautiful Soup, UTidylib, libxml etc.. (see many past discussions).
Uche's article: http://www.xml.com/pub/a/2004/09/08/pyxml.html may be of interest.





More information about the Python-list mailing list