I known my answer will not be received well by most, but that was the fastest way I could find, I did a Python script with XunitParser module made that a breeze (I can even test it better or use other tools to run them).
Just write to a temporary file using the tmp() folder and then sh or bat the python script and give the output file as argument, output into the wanted format and just read the file into Jenkins pipeline.
All those little Python script have save me hours so far compare to messing around into the Jenkins "cripple" Groovy. Just doing a iteration on list doesn't work as it is suppose too into that Groovy implementation! @NonCPS is a bag of crab so far for me (same function does or doesn't return the same result with or without the @NonCPS, some function I had written where working until some update where I had to add the @NonCPS by updating Jenkins). Having to allow all the operations (map hash, file getAbsolutePath, operator string to string, ...) but can launch a shell or batch operation that can access whatever folder.
May sound harsh on Jenkins, but every new commer have question on how to do simple stuff (this include myself, I'm no different here! the struggle is real, especially for people who did not touch any groovy before and realize they don't really have a full features Groovy engine to play with) because we can't rely on Groovy way of doing those thing, because those way doesn't work most of the time into that implementation or need to be tweak a lots to make them working. Many of those questions are left without answer since nobody really know how to do them properly into that script engine.