[lxml-dev] Element children not right?

Stefan Behnel stefan_ml at behnel.de
Mon Jul 16 00:24:50 CEST 2007


Mike Meyer wrote:
> On Sun, 15 Jul 2007 19:46:31 +0200 Stefan Behnel <stefan_ml at behnel.de> wrote:
>>> Right. But I don't need the extra filter in ElementTree - it returns
>>> just the element children and that's what it's documented as doing. I
>>> quite literally found this when I took working ElementTree code and
>>> tried to move it to lxml's implementation of ElementTree (and then
>>> moved back to ElementTree rather than use test on the tag attributes
>>> type).
>> Hmm, I see your point. Maybe we should provide an ElemenTree compatible parser
>> that strips comments and PIs from the document. That would at least help in
>> porting existing code.
> 
> I think that would certainly solve the problem I ran into.

The current trunk has an "ETCompatXMLParser" class that is a subclass of
XMLParser with a different default setup. Currently that only means that
remove_comments and remove_pis are active by default. Please try setting it as
a default parser on your side and report back if you find any further
incompatibilities.

BTW: ETCompatXMLParser will not become the default parser in lxml.etree, it
will only be available to simplify code portability.

Stefan




More information about the lxml-dev mailing list