Generate XML

I am not able to generate an XML with this structure is breaking lines

And node “set1” is giving an error the first time you run the code, why?

I found the solution in this post