In [1]: from lxml import etree
I have an HTML document:
In [2]: root = etree.fromstring(u'''<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">\n<HTML></HTML>''', etree.HTMLParser())
Its doctype parses correctly:
In [3]: root.getroottree().docinfo.doctype
Out[3]: u'<!DOCTYPE html PUBLIC "-//IETF//DTD HTML//EN">'
But when it is serialized, I lose it:
In [4]: etree.tostring(root.getroottree(), method='html')
Out[4]: '<html></html>'
What should I do to get this document serialized?
Debian GNU / Linux, Sid. Python 2.6.6. lxml 2.2.8-2.
liori source
share