https://ocsigen.org/eliom/1.3.4/manual/html
The syntax is fairly lightweight, just << followed by valid, type checked XHTML ended by >>. There are also antiquotations so you can use it as a templating language.
For those of us generating XML from C I wrote a hairy set of C macros:
https://github.com/libguestfs/libguestfs/blob/master/common/...
so you can write code like this (which is not fully checked at compile time of course):
https://github.com/libguestfs/libguestfs/blob/4aa712d551f9d4...