<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def setattr(self, key, value):
 u"""Sets an attribute on a node. 'text2' 'val' """

        if key == 'text':
            self._xml.text = str(value)
        else:
            self._xml.set(key, str(value))