def _render(tree):
    """Try rendering as HTML, then XML, then give up."""
    try:
        return force_unicode(_serialize(tree))
    except Exception, e:
        log.error('HTML: %r' % e, exc_info=sys.exc_info())
        try:
            return force_unicode(tree.toxml())
        except Exception, e:
            log.error('XML: %r' % e, exc_info=sys.exc_info())
            return u''
Try rendering as HTML, then XML, then give up.
v2ex/babel/ext/bleach/__init__.py