text = (
    "<x>hello, <z>keep me</z> and <y>ignore me</y>, and here's some <y>more</y> text</x>"
    )
tree = etree.fromstring(text)
print(etree.tostring(tree, pretty_print=True))
etree.strip_tags(tree, 'z')
print('-' * 72)
print(etree.tostring(tree, pretty_print=True))
etree.strip_elements(tree, 'y', with_tail=False)
print('-' * 72)
print(etree.tostring(tree, pretty_print=True))
удаление встроенных тегов с помощью python lxml