Parse arrays and attributes in the return XML

Properly parse repeated elements into arrays, and attributes as objects.

Added the XML object to the return array.