Check for empty array
Try to properly build XML document root