HTML -> HTMLGen (or similiar)

Walter Dörwald walter at
Thu Apr 10 10:21:52 CEST 2003

VanL wrote:

> Hello,
> I have a bunch of existing HTML that I need to integrate into a new web 
> app.  I would ideally like to use one of the existing HTML generation 
> systems (HTMLgen, HyperText, any others) but I don't want to have to 
> build up an equivalent representation for the many pages I need to work 
> with.

You can use XIST for that (available from

Code looks like this:

from ll.xist import parsers, presenters
e = parsers.parseURL("", tidy=True)
print e.repr(presenters.CodePresenter())

This dumps the Python website as an XIST DOM constructor, looking
something like this (with whitespace removed):

    ll.xist.ns.xml.XMLStyleSheet('href="./css/ht2html.css" ..."'),
       xsc.Comment(' THIS PAGE IS AUTOMATICALLY ... '),
       xsc.Comment(' Fri Apr  4 10:59:44 2003 '),
       xsc.Comment(' USING HT2HTML 2.0 '),
       xsc.Comment(' SEE '),
       xsc.Comment(' User-specified headers:\nTitle: Python ...'),
             'Python Language Website'

You might want to shorten the class names (i.e. removing the
"ll.xist.ns." part). The final output code might look like

from ll.xist import xsc
from ll.xist.ns import xml, html

e = xsc.Frag(
    xml.XMLStyleSheet('href="./css/ht2html.css" ..."'),
       xsc.Comment(' THIS PAGE IS AUTOMATICALLY ... '),

print e.asBytes(encoding="utf-8")

Hope that helps!

    Walter Dörwald

More information about the Python-list mailing list