Ejemplo n.º 1
0
def getElementById(element, id):
    try:
        element_id = DOM.getAttribute(element, "id")
    except:
        element_id = None
    if element_id is not None and element_id == id:
        return element

    child = DOM.getFirstChild(element)
    while child is not None:
        ret = getElementById(child, id)
        if ret is not None:
            return ret
        child = DOM.getNextSibling(child)

    return None
Ejemplo n.º 2
0
def getElementById(element, id):
    try:
        element_id = DOM.getAttribute(element, "id")
    except:
        element_id = None
    if element_id is not None and element_id == id:
        return element

    child = DOM.getFirstChild(element)
    while child is not None:
        ret = getElementById(child, id)
        if ret is not None:
            return ret
        child = DOM.getNextSibling(child)

    return None
Ejemplo n.º 3
0
def getElementsByTagName(element, tagname):
    try:
        element_tagname = element.nodeName
        element_tagname = str(element_tagname).lower()
    except:
        element_tagname = None
    if element_tagname is not None and element_tagname == tagname:
        return [element]

    res = []
    child = DOM.getFirstChild(element)
    while child is not None:
        for el in getElementsByTagName(child, tagname):
            res.append(el)
        child = DOM.getNextSibling(child)

    return res
Ejemplo n.º 4
0
def getElementsByTagName(element, tagname):
    try:
        element_tagname = element.nodeName # DOM.getAttribute(element, "nodeName")
        element_tagname = str(element_tagname).lower()
    except:
        element_tagname = None
    if element_tagname is not None and element_tagname == tagname:
        return [element]

    res = []
    child = DOM.getFirstChild(element)
    while child is not None:
        for el in getElementsByTagName(child, tagname):
            res.append(el)
        child = DOM.getNextSibling(child)

    return res