def remove_all_but_text_nodes()

in python/mhtml_to_json.py [0:0]


def remove_all_but_text_nodes(node, valid_tags):
    for child in node:
        remove_all_but_text_nodes(child, valid_tags)
    if node.tag not in valid_tags and "itemprop" not in node.keys():
        for valid_child in node:
            node.addnext(valid_child)
        if node.getparent() is not None:
            node.getparent().remove(node)