def setattr(self, key, value):
        u"""Sets an attribute on a node.

        >>> xml = etree.Element('root')
        >>> Node(xml).setattr('text', 'text2')
        >>> Node(xml).getattr('text')
        'text2'
        >>> Node(xml).setattr('attr', 'val')
        >>> Node(xml).getattr('attr')
        'val'
        """
        if key == 'text':
            self._xml.text = str(value)
        else:
            self._xml.set(key, str(value))
u"""Sets an attribute on a node.

        >>> xml = etree.Element('root')
        >>> Node(xml).setattr('text', 'text2')
        >>> Node(xml).getattr('text')
        'text2'
        >>> Node(xml).setattr('attr', 'val')
        >>> Node(xml).getattr('attr')
        'val'