How to send response in XML via Lotusscript agent

I have a lotusscript agent which has a url address. This agent normally receives a POST with a String value which contains an XML. This string will be converted to a XML, we will parse the XML and eventually send a XML in string back. This is a piece of the code of the Lotusscript agent where we send the response (in XML) back:

Print {content-type:text/xml;charset=utf-8}
Print returnXML 

Whereby the returnXML has a XML which is built up for example like this:

returnXML = “<?xml version=”“1.0"” encoding=““UTF-8"”?>”
returnXML = returnXML + DTD
returnXML = returnXML + “<cXML timestamp=”“” +cxmlTimestamp + “”" payloadID=“”" + payloadID +“”“>”
returnXML = returnXML + “<Response>”
…
returnXML = returnXML + “</cXML>”

But whenever someone does a Post, instead of the XML they see:

<html>
<head>
</head>
<body text="#000000">
Start goodreceipt agent
Save GR cxml
GR is processed
content-type:text/xml;charset=utf-8
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE cXML SYSTEM 'http://xml.cxml.org/schemas/cXML/1.2.043/cXML.dtd'><cXML timestamp="2020-06-25T02:33:34+05:30" payloadID="24234234"><Response><Status code="200" text="OK" /></Response></cXML>
</body>
</html>

So they see also other print statements and next to that:
Print {content-type:text/xml;charset=utf-8}

Must set the content headers and must not be printed as a print statement.

Any advice how to correct this?

It is VERY improtant, that there are NO other prints within your code and that the Content- Type- print is the VERY FIRST in your code. If your first print is anything other than the content type, then Domino will automatically create an HTML output.

By the way: Using "Prints" in an agent to print out states of the agent is very bad practice. Every Domino Admin will hate you for doing this. Use proper logging (e.g. by using OpenLog from OpenNTF) and stop spamming the server console with agent print statements.

Thanks Torsten, love your replies on point as always (like on Stackoverflow)!