select_prev_sibling

returns the sibling that is from previous element.

Source


def select_prev_sibling(self):
    ret = pyNodeList()
    n = self.prev_all()
    if isinstance(n, pyNode):
        tmp = pyNodeList()
        tmp.append(n)
        n = tmp
    if isinstance(n, pyNodeList) and len(n) != 0:
        for elem in n:
            if elem.has_child():
                for child in elem.children():
                    ret.append(child)
                    descendants = child.descendant()
                    if isinstance(descendants, pyNode):
                        ret.append(descendants)
                    elif isinstance(descendants, pyNodeList):
                        ret.extend(descendants)
    if len(ret) == 1: return ret[0]
    else: return ret