def _remove_whitespace_nodes(self, node, unlink=True):
        """
        删除空白无用节点
        """
        remove_list = []
        for child in node.childNodes:
            if child.nodeType == Node.TEXT_NODE and not child.data.strip():
                remove_list.append(child)
            elif child.hasChildNodes():
                self._remove_whitespace_nodes(child, unlink)
        for node in remove_list:
            node.parentNode.removeChild(node)
            if unlink:
                node.unlink()
def _remove_whitespace_nodes(self, node, unlink=True):
        """
        删除空白无用节点
        """
        remove_list = []
        for child in node.childNodes:
            if child.nodeType == Node.TEXT_NODE and not child.data.strip():
                remove_list.append(child)
            elif child.hasChildNodes():
                self._remove_whitespace_nodes(child, unlink)
        for node in remove_list:
            node.parentNode.removeChild(node)
            if unlink:
                node.unlink()
def _remove_whitespace_nodes ( self , node , unlink = True ) : remove_list = [ ] for child in node . childNodes : if child . nodeType == Node . TEXT_NODE and not child . data . strip ( ) : remove_list . append ( child ) elif child . hasChildNodes ( ) : self . _remove_whitespace_nodes ( child , unlink ) for node in remove_list : node . parentNode . removeChild ( node ) if unlink : node . unlink ( )
删除空白无用节点
删除空白无用节点