select_attr

returns elements that have the given attribute and the value.

Arguments

Source


def select_attr(self, attr, value):
    ret = pyNodeList()
    for node in self:
        a = node.attr(attr)
        if a is not None and a == value:
            ret.append(node)
    if len(ret) == 1: return ret[0]
    else: return ret