'Get a string representation of this XML fragment.
@param indent: The indent to be used in formatting the output.
@type indent: int
@return: A I{pretty} string.
@rtype: basestring'

def str(self, indent=0):

    tab = ('%*s' % ((indent * 3), ''))
    result = []
    result.append(('%s<%s' % (tab, self.qname())))
    result.append(self.nsdeclarations())
    for a in [unicode(a) for a in self.attributes]:
        result.append(('    %s' % a))
    if self.isempty():
        result.append('/>')
        return ''.join(result)
    result.append('>')
    if self.hasText():
        result.append(self.text.escape())
    for c in self.children:
        result.append('\n')
        result.append(c.str((indent + 1)))
    if len(self.children):
        result.append(('\n%s' % tab))
    result.append(('</%s>' % self.qname()))
    result = ''.join(result)
    return result
