That xml looks all kinds of corrupt to me. I don’t think that in Python your combination of three-quotes for a multiline string, and \n for newline is doing what you expect.
Before you try to post your action, just build the xml file and save it, then read it in an editor to see how it looks.
When posting xml or any code to the forum, highlight it and select the “Code” tag that looks like </>
just above the editor window.
I strongly suggest you use Python’s XML libraries (I use ElementTree myself, but there are several) rather than just building a big string. That way you can do things like set a node value to <[CDATA[ my long relevance or actionscript ]]>
and let the XML library to all of the translations and encodings for you.