child

returns specified child elements.

Arguments

Source


def child(self, child_tag = None):
    if child_tag is None: return self.children()
    ret = pyNodeList()
    for node in self:
        ch = node.child(child_tag)
        if isinstance(ch, pyNodeList) and len(ch) != 0:
            ret.extend(ch)
        elif isinstance(ch, pyNode):
            ret.append(ch)
    if len(ret) == 1: return ret[0]
    else: return ret