In this section, I think I would do a couple things:
1) Group the element creation at the top, and the element appending at the bottom, so it's a little easier to follow.
2) Use a more descriptive var name instead of `$packageSxe`. Maybe `$packageXml`?