Library to generate xml data from key values

I'm thinking of starting a library to convert key value dictionaries (and possibly attachments) to xlsform data (xml representation of survey answers) while checking that the constraint of the corresponding xlsform are satisfied.

So to summarize, you provide your json dictionary with the key/values, the xlsform xml file and it provides you either the xml of the encoded answers or a list of errors.

It feels like something like this must already exist, but I didn't find it so far. Am I wrong that id does not exist?