[lxml-dev] Proposal: Better html5lib Support

Armin Ronacher armin.ronacher at active-4.com
Mon Jul 14 22:29:06 CEST 2008


Stefan Behnel <stefan_ml <at> behnel.de> writes:


> Yes. Although this isn't really a bug (you should use the Comment factory to
> create a comment, not the _Comment or HtmlComment classes), this seems to be a
> common misconception especially by new users. This behaviour will change in
> lxml 2.2, where calling an Element class already creates a new Element.
There is no Comment factory in lxml.html, just in lxml.etree which i use right
now.  But that one creates a different object.

> > (The only way is to use html.fromstring
> > with the comment there, but that's an ugly hack).
> 
> Using the etree.Comment() factory is just fine and will do the right thing.
But it returns a lxml.etree._Comment and not an lxml.html.HtmlComment or I'm
missing something.


Regards,
Armin



More information about the lxml-dev mailing list