[lxml-dev] lxml.objectify.deannotate refuses to clean nil nodes
Robert Pierce
robert at smithpierce.net
Thu Jun 4 19:23:02 CEST 2009
I agree! Solves my problem and then some.
On Thu, Jun 4, 2009 at 8:30 AM, John Lovell <jlovell at nwesd.org> wrote:
> My comments would be: brilliant, useful, wonderful!
>
> ...
>
> That sounds like functionality that belongs into lxml.etree, although it's
> partly available in lxml.html already. What about adding some more, then?
>
> - 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
>
> Since lxml.html provides a drop_tag() Element method, I considered
> drop_tags() for the last one, but thought that "strip_*" might be slightly
> better for consistency here. Alternatively, we might use "drop_*" for
> everything, but "strip" is a common thing in Python, while "drop" isn't.
> Plus, there are "drop_*()" /methods/ in lxml.html, which make sense on an
> Element and do not traverse into subtrees. "strip" makes no sense in that
> context.
>
> I also vote for functions instead of methods here since they work on
> complete (sub-)trees rather than a single Element object. A function makes
> this clearer.
>
> Comments?
>
> Stefan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/lxml-dev/attachments/20090604/b3d8b836/attachment.htm
More information about the lxml-dev
mailing list