[lxml-dev] lxml.objectify.deannotate refuses to clean nil nodes
Stefan Behnel
stefan_ml at behnel.de
Sat Jun 6 10:49:24 CEST 2009
Hi,
Robert Pierce wrote:
> On Thu, Jun 4, 2009 at 8:30 AM, John Lovell wrote:
>> Stefan Behnel wrote:
>>> - strip_attributes(tree, *attribute_names)
>>> remove all named attributes from a tree
>>>
>>> - strip_elements(tree, *element_names)
>>> remove all named elements from a tree, including their subtrees (alt:
>>> "strip_subtrees")
>>>
>>> - strip_tags(tree, *element_names)
>>> remove all named elements from a tree, merging their children and text
>>> content into their parents
Done:
https://codespeak.net/viewvc/?view=rev&revision=65612
https://codespeak.net/viewvc/lxml/trunk/src/lxml/cleanup.pxi?view=markup&pathrev=65612
>>> Comments?
>>
>> My comments would be: brilliant, useful, wonderful!
>
> I agree! Solves my problem and then some.
Since you two seem to be very happy about this feature, what about writing
up some docs/doctests for it?
A new section here sounds like the right place:
http://codespeak.net/svn/lxml/trunk/doc/api.txt
-> http://codespeak.net/lxml/api.html
Maybe the tutorial could also benefit from a short reference.
Holger, could you replace the current deannotate() implementation in
lxml.objectify and add the xsl:nil cleanup option as we discussed? I expect
it to be a little slower than before due to the more general
implementation. If you have some code at your hands to benchmark it, please do.
Unless Ian (or someone else) beats me to it, I'll also look through
lxml.html next week to check for places where this can be used. For
example, clean.py looks like an obvious candidate.
Stefan
More information about the lxml-dev
mailing list