I agree! Solves my problem and then some.<br><br><div class="gmail_quote">On Thu, Jun 4, 2009 at 8:30 AM, John Lovell <span dir="ltr"><<a href="mailto:jlovell@nwesd.org">jlovell@nwesd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
My comments would be: brilliant, useful, wonderful!<br>
<br>
...<br><div><div class="h5">
<br>
That sounds like functionality that belongs into lxml.etree, although it's partly available in lxml.html already. What about adding some more, then?<br>
<br>
- strip_attributes(tree, *attribute_names)<br>
remove all named attributes from a tree<br>
<br>
- strip_elements(tree, *element_names)<br>
remove all named elements from a tree, including their subtrees (alt:<br>
"strip_subtrees")<br>
<br>
- strip_tags(tree, *element_names)<br>
remove all named elements from a tree, merging their children and text content into their parents<br>
<br>
Since lxml.html provides a drop_tag() Element method, I considered<br>
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.<br>
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.<br>
<br>
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.<br>
<br>
Comments?<br>
<br>
Stefan<br>
<br></div></div></blockquote></div><br>