How to parse XHTML with xml.parsers.xmlproc?

Martin von Loewis loewis at
Mon Sep 17 10:54:37 CEST 2001

Paavo Hartikainen <pahartik at> writes:

> These are the errors that parsers gives:
>   fatal: End tag for 'head' seen, but 'meta' expected
>   fatal: End tag for 'html' seen, but 'meta' expected
>   fatal: Premature document end, element 'meta' not closed
> I am sure it is just because it does not know XHTML DTD.

I'm pretty sure this is not the problem. Instead, it looks like your
document has a structure like

<head><meta http-equiv="something"></head>

Well, this is ill-formed XML. You need a closing meta tag before you
can close the head tag. You can, of course, make use of the "empty
content" abbreviation of XML.

As for finding DTDs: If your document contains PUBLIC identifier,
xmlproc will attempt to search catalogs. If there is only a SYSTEM
identifier, it will interpret this as an URL. If it looks like a
relative path name, it will look for the DTD relative to the current


More information about the Python-list mailing list