def _flattenText(elem):
    """
    Returns the text in an element and all child elements, with the tags
    removed.
    """
    text = ""
    if elem.text is not None:
        text = elem.text
    for ch in elem:
        text += _flattenText(ch)
        if ch.tail is not None:
            text += ch.tail
    return text