I believe I found a suitable workaround, and I was inspired by volka's post.
My attempts to generate a well-formed XML from scratch using DOM/XML all failed. It really looks like some methods are missing, I even listed all methods of the DomDocument class with the
get_class_methods function, and none of them helped me.
However, volka's post reminded me I could use domxml_open_mem with an "empty template" (actually, it cannot be totally empty, but this is not a probl) to force DOM to initialize its objects the right way, and then I can proceed from this point adding my own elements to the tree skeleton.
I don't know if this was volka's original suggestion but, so far, it seems to do the job for me (and it's actually easier than doing
all by hand

)
Thks, volka
Best,
Andre