<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def text_length(elem):
 """Returns length of the content in this element. Return value is not correct but it is **good enough***. """


    if not elem:
        return 0

    value = elem.value()

    try:
        value = len(value)
    except:
        value = 0

    try:
        for a in elem.elements:
            value += len(a.value())
    except:
        pass

    return value