It's a bit weird to name the function printXmlWithHeaders() and doing this checking inside the code... Maybe the function is wider in purpose and invoked also with JSON?

In that case, maybe we should do a `"$encoding" == "JSON"` and apply the python mtool beatifier in that case.