def getChild(elem, index):
    """
    Get a child of the DOM element by specifying an index.
    """
    count = 0
    child = elem.firstChild
    while child:
        next = child.nextSibling
        if child.nodeType == 1:
            if index == count:
                return child
            count += 1
        child = next
    return None