One more style nitpick: this line is too long.

Try something like this:

     # At the top of the file
     from textwrap import dedent

    # When setting the return value...
    dedent("""
        XML string...
        goes here.
    """).strip()