How to add !DOCTYPE node using XMLDocument

I want to add !DOCTYPE into an XML I’m generating.

I don’t see any way to add this, please help

Do you write a preference file? Then use the correct API with MBS for instance or macOS lib.