'Clears the contents of the specified element.
The element to clear is specified using ``source`` and ``xpath``. They
have exactly the same semantics as with `Get Element` keyword.
The resulting XML structure is returned, and if the ``source`` is
an already parsed XML structure, it is also modified in place.
Clearing the element means removing its text, attributes, and children.
Element\'s tail text is not removed by default, but that can be changed
by giving ``clear_tail`` a true value (see `Boolean arguments`). See
`Element attributes` section for more information about tail in
general.
Examples using ``${XML}`` structure from `Example`:
| Clear Element            | ${XML}   | xpath=first |
| ${first} = | Get Element | ${XML}   | xpath=first |
| Elements Should Be Equal | ${first} | <first/>    |
| Clear Element            | ${XML}   | xpath=html/p/b | clear_tail=yes |
| Element Text Should Be   | ${XML}   | Text with italics. | xpath=html/p | normalize_whitespace=yes |
| Clear Element            | ${XML}   |
| Elements Should Be Equal | ${XML}   | <example/> |
Use `Remove Element` to remove the whole element.'

def clear_element(self, source, xpath='.', clear_tail=False):

    source = self.get_element(source)
    element = self.get_element(source, xpath)
    tail = element.tail
    element.clear()
    if (not is_truthy(clear_tail)):
        element.tail = tail
    return source
