How to produce XML comments in the result of pub.xml:documentToXMLString?

Hello,

I have a Document which is converted to an XML string via the service pub.xml:documentToXMLString. I’d like to have some XML comments at certain places in the produced XML string, i.e. fragments of type . Is it possible to prepare the document in a way that after calling of documentToXMLString the XML comments are generated automatically? I’d like to avoid the after processing of the result string to insert the XML comments at the right places.

Thank you for any hints.