select_parent

[internal] returns elements that have at least one child or text.

Source


def select_parent(self):
    ret = pyNodeList()
    for node in self:
        if len(node.children()) != 0 or len(node.text()) != 0:
            ret.append(node)
    if len(ret) == 1: return ret[0]
    else: return ret